Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/support http proxy #29

Merged
merged 7 commits into from
Dec 12, 2024
Prev Previous commit
Next Next commit
fix(server)!: improve HTTP server configuration
Refactored HTTP server initialization to include proper timeouts for improved stability and resource management. Updated logging message for SOCKS5 server to use consistent capitalization. Removed redundant build directive for cleaner code.
  • Loading branch information
ryanbekhen committed Dec 12, 2024
commit 656d7f68f44dd0097b0c737bebabaab9d6c1473f
15 changes: 11 additions & 4 deletions nanoproxy.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build !test

package main

import (
Expand Down Expand Up @@ -90,13 +88,22 @@ func main() {

go func() {
logger.Info().Msgf("Starting HTTP proxy server on %s://%s", cfg.Network, cfg.ADDRHttp)
if err := http.ListenAndServe(cfg.ADDRHttp, httpServer); err != nil {

server := &http.Server{
Addr: cfg.ADDRHttp,
Handler: httpServer,
ReadTimeout: 15 * time.Second,
WriteTimeout: 15 * time.Second,
IdleTimeout: 60 * time.Second,
}

if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
logger.Fatal().Msg(err.Error())
}
}()

go func() {
logger.Info().Msgf("Starting socks5 server on %s://%s", cfg.Network, cfg.ADDR)
logger.Info().Msgf("Starting SOCKS5 server on %s://%s", cfg.Network, cfg.ADDR)
if err := sock5Server.ListenAndServe(cfg.Network, cfg.ADDR); err != nil {
logger.Fatal().Msg(err.Error())
}
Expand Down
Loading