"gopkg.in/natefinch/lumberjack.v2"
"io"
"log"
- "math/rand"
"net/http"
"os"
"path/filepath"
"runtime"
- "time"
)
//go:embed mobius/config
)
func main() {
- rand.Seed(time.Now().UnixNano())
-
ctx, cancel := context.WithCancel(context.Background())
// TODO: implement graceful shutdown by closing context
// }
// }()
- basePort := flag.Int("bind", defaultPort, "Bind address and port")
+ netInterface := flag.String("interface", "", "IP addr of interface to listen on. Defaults to all interfaces.")
+ basePort := flag.Int("bind", defaultPort, "Base Hotline server port. File transfer port is base port + 1.")
statsPort := flag.String("stats-port", "", "Enable stats HTTP endpoint on address and port")
configDir := flag.String("config", defaultConfigPath(), "Path to config root")
version := flag.Bool("version", false, "print version and exit")
logger.Fatal(err)
}
logger.Infow("Config dir initialized at " + *configDir)
-
} else {
logger.Infow("Existing config dir found. Skipping initialization.")
}
logger.Fatalw("Configuration directory not found. Correct the path or re-run with -init to generate initial config.", "path", configDir)
}
- srv, err := hotline.NewServer(*configDir, *basePort, logger, &hotline.OSFileStore{})
+ srv, err := hotline.NewServer(*configDir, *netInterface, *basePort, logger, &hotline.OSFileStore{})
if err != nil {
logger.Fatal(err)
}
}
f.Close()
}
-
}
return nil