checker: Add offline mode which assumes student default parameters
This commit is contained in:
parent
8632db8e99
commit
55b1af83f0
@ -560,14 +560,24 @@ func minTunnelVersion(std *adlin.Student, suffixip int) (int, error) {
|
||||
return minversion, nil
|
||||
}
|
||||
|
||||
func studentChecker(std *adlin.Student, also_check_matrix bool) {
|
||||
func studentChecker(std *adlin.Student, also_check_matrix bool, offline bool) {
|
||||
tuns, err := std.GetActivesTunnels()
|
||||
if err != nil {
|
||||
if offline {
|
||||
tuns, err = std.GetDefaultTunnels()
|
||||
if err != nil {
|
||||
if verbose {
|
||||
log.Printf("SKip %s as I'm unable to generate default tunnels: %s", std.Login, err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if verbose2 {
|
||||
log.Printf("SKip %s due to error when getting active tunnels: %s", std.Login, err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
if verbose2 && len(tuns) == 0 {
|
||||
log.Printf("%s has no active tunnels: %s", std.Login, err.Error())
|
||||
}
|
||||
@ -585,7 +595,7 @@ func studentChecker(std *adlin.Student, also_check_matrix bool) {
|
||||
}
|
||||
std.OnPong(true)
|
||||
|
||||
if tunnel_version == 2147483647 || tunnel_version == 0 {
|
||||
if !offline && (tunnel_version == 2147483647 || tunnel_version == 0) {
|
||||
log.Printf("%s unknown tunnel version: %d skipping tests (%v)", std.Login, tunnel_version, err)
|
||||
return
|
||||
}
|
||||
@ -809,7 +819,7 @@ func studentChecker(std *adlin.Student, also_check_matrix bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func studentsChecker() {
|
||||
func studentsChecker(offline bool) {
|
||||
students, err := adlin.GetStudents()
|
||||
if err != nil {
|
||||
log.Println("Unable to check students:", err)
|
||||
@ -821,6 +831,6 @@ func studentsChecker() {
|
||||
|
||||
for istd, s := range students {
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
go studentChecker(s, istd%10 == check_matrix_for)
|
||||
go studentChecker(s, istd%10 == check_matrix_for, offline)
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,12 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
offline := false
|
||||
|
||||
var dsn = flag.String("dsn", adlin.DSNGenerator(), "DSN to connect to the MySQL server")
|
||||
flag.BoolVar(&verbose, "verbose", verbose, "Enable verbose mode")
|
||||
flag.BoolVar(&verbose2, "verbose2", verbose2, "Enable more verbose mode")
|
||||
flag.BoolVar(&offline, "offline", offline, "Enable offline mode (doesn't check what wg report)")
|
||||
flag.Parse()
|
||||
|
||||
if verbose2 && !verbose {
|
||||
@ -44,7 +47,7 @@ func main() {
|
||||
log.Printf("%s: %s", std_login, err.Error())
|
||||
} else {
|
||||
log.Printf("Checking %s...", std.Login)
|
||||
studentChecker(std, true)
|
||||
studentChecker(std, true, offline)
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,14 +62,14 @@ func main() {
|
||||
defer ticker.Stop()
|
||||
|
||||
// Launch checker
|
||||
studentsChecker()
|
||||
studentsChecker(offline)
|
||||
loop:
|
||||
for {
|
||||
select {
|
||||
case <-interrupt:
|
||||
break loop
|
||||
case <-ticker.C:
|
||||
studentsChecker()
|
||||
studentsChecker(offline)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,6 +225,13 @@ func (student *Student) GetActivesTunnels() (ts []*TunnelToken, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (student *Student) GetDefaultTunnels() (ts []*TunnelToken, err error) {
|
||||
t := &TunnelToken{IdStudent: student.Id}
|
||||
ts = append(ts, t)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (student *Student) GetActivesTunnelsPubKey() (ts []ed25519.PublicKey, err error) {
|
||||
var activeTuns []*TunnelToken
|
||||
activeTuns, err = student.GetActivesTunnels()
|
||||
|
Reference in New Issue
Block a user