2
0

chat.go 1000 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package main
  2. // Configuration - edit source code and recompile to change settings
  3. // To disable a service: set its port to 0 or delete its .go file
  4. const (
  5. HTTP_PORT = 80 // Web interface (set to 0 to disable)
  6. HTTPS_PORT = 443 // TLS web interface (set to 0 to disable)
  7. SSH_PORT = 22 // Anonymous SSH chat (set to 0 to disable)
  8. DNS_PORT = 53 // DNS TXT chat (set to 0 to disable)
  9. )
  10. func main() {
  11. // SSH Server
  12. if SSH_PORT > 0 {
  13. go func() {
  14. StartSSHServer(SSH_PORT)
  15. }()
  16. }
  17. // DNS Server
  18. if DNS_PORT > 0 {
  19. go func() {
  20. StartDNSServer(DNS_PORT)
  21. }()
  22. }
  23. // HTTP/HTTPS Server
  24. // TODO: Implement graceful shutdown with signal handling
  25. if HTTP_PORT > 0 || HTTPS_PORT > 0 {
  26. if HTTPS_PORT > 0 {
  27. go func() {
  28. StartHTTPSServer(HTTPS_PORT, "cert.pem", "key.pem")
  29. }()
  30. }
  31. if HTTP_PORT > 0 {
  32. StartHTTPServer(HTTP_PORT)
  33. } else {
  34. // If only HTTPS is enabled, block forever
  35. select {}
  36. }
  37. } else {
  38. // If no servers enabled, block forever
  39. select {}
  40. }
  41. }