checker: for each tun IP
This commit is contained in:
parent
0af7437693
commit
9cd237daff
@ -129,7 +129,7 @@ func check_https(domain, ip string) (err error) {
|
||||
|
||||
// Main
|
||||
|
||||
func minTunnelVersion(std adlin.Student) (int, error) {
|
||||
func minTunnelVersion(std adlin.Student, suffixip int) (int, error) {
|
||||
tunnels, err := std.GetTunnelTokens()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -141,7 +141,7 @@ func minTunnelVersion(std adlin.Student) (int, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
if tunnel.Dump != nil && tunnel.Version < minversion {
|
||||
if tunnel.Dump != nil && tunnel.Version < minversion && suffixip == tunnel.SuffixIP {
|
||||
minversion = tunnel.Version
|
||||
}
|
||||
}
|
||||
@ -161,11 +161,17 @@ func studentsChecker() {
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
// Check ping
|
||||
std := s
|
||||
stdIP := adlin.StudentIP(std.Id).String() + "1"
|
||||
tuns, err := std.GetActivesTunnels()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, tun := range tuns {
|
||||
stdIP := tun.GetStudentIP()
|
||||
go check_ping(stdIP, func(pkt *ping.Packet) {
|
||||
tunnel_version, err := minTunnelVersion(std)
|
||||
tunnel_version, err := minTunnelVersion(std, tun.SuffixIP)
|
||||
if verbose {
|
||||
log.Printf("%s PONG; version=%d (%v)\n", std.Login, tunnel_version, err)
|
||||
log.Printf("%s PONG (on %x); version=%d (%v)\n", std.Login, tun.SuffixIP, tunnel_version, err)
|
||||
}
|
||||
std.OnPong(true)
|
||||
|
||||
@ -262,3 +268,4 @@ func studentsChecker() {
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,8 +104,12 @@ type TunnelToken struct {
|
||||
}
|
||||
|
||||
func (tt *TunnelToken) GetStudentIP() string {
|
||||
if tt.SuffixIP == 0 {
|
||||
return fmt.Sprintf("%s%x", StudentIP(tt.IdStudent).String(), 1)
|
||||
} else {
|
||||
return fmt.Sprintf("%s%x", StudentIP(tt.IdStudent).String(), tt.SuffixIP)
|
||||
}
|
||||
}
|
||||
|
||||
func TokenFromText(token string) []byte {
|
||||
sha := sha512.Sum512([]byte(token))
|
||||
|
@ -60,7 +60,7 @@ func GetStudentTunnelIPs(student adlin.Student) (ips []string) {
|
||||
ips = append(ips, adlin.StudentIP(student.Id).String()+"1")
|
||||
} else {
|
||||
for _, t := range ts {
|
||||
ips = append(ips, t.GetTunnelIP())
|
||||
ips = append(ips, t.GetStudentIP())
|
||||
}
|
||||
}
|
||||
return
|
||||
|
Reference in New Issue
Block a user