Skip to content

Commit

Permalink
feat: add IPv6 support (#475)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohammed Rabil <mail@rabil.me>
  • Loading branch information
lavish440 and rabilrbl authored Dec 17, 2024
1 parent a73edb8 commit 7f2a44a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
1 change: 1 addition & 0 deletions cmd/jiotv_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func JioTVServer(jiotvServerConfig JioTVServerConfig) error {

app := fiber.New(fiber.Config{
Views: engine,
Network: fiber.NetworkTCP,
StreamRequestBody: true,
CaseSensitive: false,
StrictRouting: false,
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func main() {
// overwrite host if --public flag is passed
if c.Bool("public") {
fmt.Println("INFO: You are exposing your server to outside your local network (public)!")
fmt.Println("INFO: Overwriting host to 0.0.0.0 for public access")
host = "0.0.0.0"
fmt.Println("INFO: Overwriting host to [::] for public access")
host = "[::]"
}
port := c.String("port")
configPath := c.String("config")
Expand Down Expand Up @@ -85,7 +85,7 @@ func main() {
&cli.BoolFlag{
Name: "public",
Aliases: []string{"P"},
Usage: "Open server to public. This will expose your server outside your local network. Equivalent to passing --host 0.0.0.0",
Usage: "Open server to public. This will expose your server outside your local network. Equivalent to passing --host [::]",
},
&cli.BoolFlag{
Name: "tls",
Expand Down
19 changes: 8 additions & 11 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ import (
"github.com/valyala/fasthttp/fasthttpproxy"
)

var (
// Log is a global logger
// initialized in main.go
// used to log debug messages and errors
Log *log.Logger
)
// Log is a global logger
// initialized in main.go
// used to log debug messages and errors
var Log *log.Logger

// GetLogger creates a new logger instance with custom settings
func GetLogger() *log.Logger {
Expand All @@ -42,7 +40,7 @@ func GetLogger() *log.Logger {
}
logger = log.New(file, "[DEBUG] ", log.Ldate|log.Ltime|log.Lshortfile)
// rotate log file if it is larger than 10MB
// neccessary to prevent filling up disk space with logs
// necessary to prevent filling up disk space with logs
logger.SetOutput(&lumberjack.Logger{
Filename: logFilePath,
MaxSize: 5, // megabytes
Expand Down Expand Up @@ -402,7 +400,6 @@ func GetJIOTVCredentials() (*JIOTV_CREDENTIALS, error) {

// WriteJIOTVCredentials writes credentials data to file
func WriteJIOTVCredentials(credentials *JIOTV_CREDENTIALS) error {

if err := store.Set("ssoToken", credentials.SSOToken); err != nil {
return err
}
Expand Down Expand Up @@ -508,18 +505,18 @@ func GetRequestClient() *fasthttp.Client {
if strings.HasPrefix(proxy, "socks5://") {
// socks5 proxy
return &fasthttp.Client{
Dial: fasthttpproxy.FasthttpSocksDialer(proxy),
Dial: fasthttpproxy.FasthttpSocksDialerDualStack(proxy),
}
} else {
// http proxy
return &fasthttp.Client{
Dial: fasthttpproxy.FasthttpHTTPDialerTimeout(proxy, 10*time.Second),
Dial: fasthttpproxy.FasthttpHTTPDialerDualStackTimeout(proxy, 10*time.Second),
}
}
}
return &fasthttp.Client{
Dial: fasthttp.DialFunc(func(addr string) (netConn net.Conn, err error) {
return fasthttp.DialTimeout(addr, 5*time.Second)
return fasthttp.DialDualStackTimeout(addr, 5*time.Second)
}),
}
}
Expand Down

0 comments on commit 7f2a44a

Please sign in to comment.