by default, only listen on localhost

This commit is contained in:
nemunaire 2016-11-19 16:17:53 +01:00 committed by nemunaire
parent a253099725
commit 6f91b0810f
3 changed files with 23 additions and 2 deletions

View File

@ -16,6 +16,25 @@ var ApiTeamsRouting = map[string]DispatchFunction{
"DELETE": deletionTeam,
}
func nginxGenMember() (string, error) {
if teams, err := fic.GetTeams(); err != nil {
return "", err
} else {
ret := ""
for _, team := range teams {
if members, err := team.GetMembers(); err == nil {
for _, member := range members {
ret += fmt.Sprintf(" if ($remote_user = \"%s\") { set $team \"%s\"; }\n", member.Nickname, team.InitialName)
}
} else {
return "", err
}
}
return ret, nil
}
}
func nginxGenTeam() (string, error) {
if teams, err := fic.GetTeams(); err != nil {
return "", err
@ -107,6 +126,8 @@ func listTeam(args []string, body []byte) (interface{}, error) {
return fic.GetTries(nil, nil)
} else if args[0] == "nginx" {
return nginxGenTeam()
} else if args[0] == "nginx-members" {
return nginxGenMember()
} else if args[0] == "binding" {
return bindingTeams()
} else if tid, err := strconv.Atoi(string(args[0])); err != nil {

View File

@ -19,7 +19,7 @@ var CloudUsername string
var CloudPassword string
func main() {
var bind = flag.String("bind", "0.0.0.0:8081", "Bind port/socket")
var bind = flag.String("bind", "127.0.0.1:8081", "Bind port/socket")
var dsn = flag.String("dsn", "fic:fic@/fic", "DSN to connect to the MySQL server")
flag.StringVar(&BaseURL, "baseurl", "http://fic.srs.epita.fr/", "URL prepended to each URL")
flag.StringVar(&SubmissionDir, "submission", "./submissions/", "Base directory where save submissions")

View File

@ -27,7 +27,7 @@ func touchStartedFile(startSub time.Duration) {
}
func main() {
var bind = flag.String("bind", "0.0.0.0:8080", "Bind port/socket")
var bind = flag.String("bind", "127.0.0.1:8080", "Bind port/socket")
var prefix = flag.String("prefix", "", "Request path prefix to strip (from proxy)")
var start = flag.Int64("start", 0, fmt.Sprintf("Challenge start timestamp (in 2 minutes: %d)", time.Now().Unix()/60*60+120))
var duration = flag.Duration("duration", 180*time.Minute, "Challenge duration")