From 94ed539e0107e006121ac31fc9b20e7d05ddade4 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sat, 18 Mar 2023 10:42:29 +0100 Subject: [PATCH] When tunnel doesn't PONG, ask to check firewall --- checker/checker.go | 8 ++++++++ libadlin/students.go | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/checker/checker.go b/checker/checker.go index 79ea136..d62d561 100644 --- a/checker/checker.go +++ b/checker/checker.go @@ -371,6 +371,14 @@ func studentChecker(std *adlin.Student, also_check_matrix bool, offline bool) { }) if err != nil && verbose { log.Printf("%s: Unable to perform ping to %s: %s", std.Login, stdIP, err.Error()) + + 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 { + 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.")) + } + } + } } } } diff --git a/libadlin/students.go b/libadlin/students.go index 70711d1..7d67bce 100644 --- a/libadlin/students.go +++ b/libadlin/students.go @@ -135,6 +135,12 @@ func (s *Student) GetStates() (ucs []*UnlockedChallenge, err error) { } } +func (s *Student) GetChallengeError(challenge_id int) (uc *ErroredChallenge, err error) { + uc = new(ErroredChallenge) + err = DBQueryRow("SELECT id_st, challenge, time, error FROM student_challenge_errors WHERE id_student = ? AND challenge = ?", s.Id, challenge_id).Scan(&uc.Id, &uc.Challenge, &uc.Time, &uc.Error) + return +} + func (s *Student) GetChallengeErrors() (ucs []*ErroredChallenge, err error) { if rows, errr := DBQuery("SELECT id_st, challenge, time, error FROM student_challenge_errors WHERE id_student = ?", s.Id); errr != nil { return nil, errr