parent
11bf5362a3
commit
d61f28875e
checker
@ -96,7 +96,7 @@ func studentChecker(std *adlin.Student, also_check_matrix bool, offline bool) {
|
|||||||
if _, err := std.UnlockChallenge(CheckMap[tunnel_version][PingResolver], ""); err != nil {
|
if _, err := std.UnlockChallenge(CheckMap[tunnel_version][PingResolver], ""); err != nil {
|
||||||
log.Printf("Unable to register challenge for %s: %s\n", std.Login, err.Error())
|
log.Printf("Unable to register challenge for %s: %s\n", std.Login, err.Error())
|
||||||
}
|
}
|
||||||
})
|
}, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Firewalled
|
// Firewalled
|
||||||
@ -368,17 +368,29 @@ func studentChecker(std *adlin.Student, also_check_matrix bool, offline bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
})
|
}, func(stats *ping.Statistics) {
|
||||||
if err != nil && verbose {
|
if verbose2 {
|
||||||
log.Printf("%s: Unable to perform ping to %s: %s", std.Login, stdIP, err.Error())
|
log.Printf("%s: %s ping statistics: %d packets transmitted, %d packets received, %v%% packet loss", std.Login, stdIP, stats.PacketsSent, stats.PacketsRecv, stats.PacketLoss)
|
||||||
|
}
|
||||||
|
if stats.PacketsRecv > 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tunnel_version, err := minTunnelVersion(std, tun.SuffixIP)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !has_test(CheckMap[tunnel_version], Firewalled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if tunnel_version, err := minTunnelVersion(std, tun.SuffixIP); err == nil {
|
|
||||||
if has_test(CheckMap[tunnel_version], Firewalled) {
|
|
||||||
if e, err := std.GetChallengeError(CheckMap[tunnel_version][Firewalled]); err == nil && len(e.Error) > 0 {
|
if e, err := std.GetChallengeError(CheckMap[tunnel_version][Firewalled]); err == nil && len(e.Error) > 0 {
|
||||||
std.RegisterChallengeError(CheckMap[tunnel_version][Firewalled], fmt.Errorf("Your host is unreachable, no more tests are performed. Check that you are not filtering the tunnel (Wireguard uses UDP datagrams), nor ICMPv6 as your host needs to respond to PING."))
|
std.RegisterChallengeError(CheckMap[tunnel_version][Firewalled], fmt.Errorf("Your host is unreachable, no more tests are performed. Check that you are not filtering the tunnel (Wireguard uses UDP datagrams), nor ICMPv6 as your host needs to respond to PING."))
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
if err != nil && verbose {
|
||||||
|
log.Printf("%s: Unable to perform ping to %s: %s", std.Login, stdIP, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ func has_test(m map[AdlinTest]int, test AdlinTest) bool {
|
|||||||
|
|
||||||
// ICMP
|
// ICMP
|
||||||
|
|
||||||
func check_ping(ip string, cb func(pkt *ping.Packet)) (err error) {
|
func check_ping(ip string, cb func(pkt *ping.Packet), cb_finished func(stats *ping.Statistics)) (err error) {
|
||||||
var pinger *ping.Pinger
|
var pinger *ping.Pinger
|
||||||
pinger, err = ping.NewPinger(ip)
|
pinger, err = ping.NewPinger(ip)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -112,6 +112,7 @@ func check_ping(ip string, cb func(pkt *ping.Packet)) (err error) {
|
|||||||
pinger.Timeout = time.Second * 5
|
pinger.Timeout = time.Second * 5
|
||||||
pinger.Count = 1
|
pinger.Count = 1
|
||||||
pinger.OnRecv = cb
|
pinger.OnRecv = cb
|
||||||
|
pinger.OnFinish = cb_finished
|
||||||
pinger.SetPrivileged(true)
|
pinger.SetPrivileged(true)
|
||||||
err = pinger.Run()
|
err = pinger.Run()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user