checker: Add new firewall tests
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
19943dcc85
commit
170bc9ae35
2 changed files with 79 additions and 28 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
|
@ -21,7 +22,8 @@ import (
|
|||
type AdlinTest int
|
||||
|
||||
const (
|
||||
HTTPonIP AdlinTest = iota
|
||||
Firewalled AdlinTest = iota
|
||||
HTTPonIP
|
||||
HTTPonAssociatedDomain
|
||||
HTTPSonAssociatedDomain
|
||||
DNSDelegation
|
||||
|
|
@ -44,6 +46,7 @@ const (
|
|||
|
||||
var CheckMap = map[int]map[AdlinTest]int{
|
||||
2: map[AdlinTest]int{
|
||||
Firewalled: 100,
|
||||
HTTPonIP: 101,
|
||||
HTTPonAssociatedDomain: 102,
|
||||
HTTPSonAssociatedDomain: 103,
|
||||
|
|
@ -53,7 +56,8 @@ var CheckMap = map[int]map[AdlinTest]int{
|
|||
HTTPSSNI: 107,
|
||||
DNSSEC: 110,
|
||||
},
|
||||
3: map[AdlinTest]int{
|
||||
/*2: map[AdlinTest]int{
|
||||
Firewalled: 200,
|
||||
HTTPonIP: 201,
|
||||
HTTPonAssociatedDomain: 202,
|
||||
HTTPSonAssociatedDomain: 203,
|
||||
|
|
@ -64,8 +68,8 @@ var CheckMap = map[int]map[AdlinTest]int{
|
|||
MatrixSrv: 208,
|
||||
MatrixClt: 209,
|
||||
DNSSEC: 210,
|
||||
},
|
||||
4: map[AdlinTest]int{
|
||||
},*/
|
||||
3: map[AdlinTest]int{
|
||||
PingResolver: 300,
|
||||
HTTPonIP: 301,
|
||||
DNSDelegation: 303,
|
||||
|
|
@ -83,6 +87,15 @@ var CheckMap = map[int]map[AdlinTest]int{
|
|||
},
|
||||
}
|
||||
|
||||
func has_test(m map[AdlinTest]int, test AdlinTest) bool {
|
||||
for k := range m {
|
||||
if k == test {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ICMP
|
||||
|
||||
func check_ping(ip string, cb func(pkt *ping.Packet)) (err error) {
|
||||
|
|
@ -105,6 +118,23 @@ func check_ping(ip string, cb func(pkt *ping.Packet)) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func check_firewall(network, ip string) error {
|
||||
port := rand.Int31n(64500) + 1024
|
||||
|
||||
conn, err := net.DialTimeout(network, fmt.Sprintf("[%s]:%d", ip, port), 3*time.Second)
|
||||
if err != nil {
|
||||
if operr, ok := err.(*net.OpError); ok && operr.Timeout() {
|
||||
// We expect a timeout here if the firewall is well setuped
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("Port %d is not filtered: %s", port, err.Error())
|
||||
}
|
||||
|
||||
conn.Close()
|
||||
return fmt.Errorf("Port %d is open", port)
|
||||
}
|
||||
|
||||
// PORT 53
|
||||
|
||||
func get_GLUE(student *adlin.Student) (aaaa net.IP, err error) {
|
||||
|
|
|
|||
Reference in a new issue