Skip to content

Commit

Permalink
http dialer default port
Browse files Browse the repository at this point in the history
  • Loading branch information
zuiwuchang committed Jan 24, 2024
1 parent e850597 commit 9da6f6d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* fix http bridge default tag prefix 'ws'
* fix bridge connect error not close source connection
* add command flags -print
* fix http/websocket dialer not set default port

# v0.0.1

Expand Down
14 changes: 12 additions & 2 deletions dialer/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,22 @@ func newHttpDialer(nk *network.Network, log *slog.Logger, opts *config.Dialer, u
}
var (
network = `tcp`
addr = u.Host
addr string
)
if opts.Network != `` {
network = opts.Network
}
if opts.Addr != `` {
if opts.Addr == `` {
if u.Port() == `` {
if secure {
addr = u.Host + `:443`
} else {
addr = u.Host + `:80`
}
} else {
addr = u.Host
}
} else {
addr = opts.Addr
}

Expand Down
14 changes: 12 additions & 2 deletions dialer/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,22 @@ func newWebsocketDialer(nk *network.Network, log *slog.Logger, opts *config.Dial
}
var (
network = `tcp`
addr = u.Host
addr string
)
if opts.Network != `` {
network = opts.Network
}
if opts.Addr != `` {
if opts.Addr == `` {
if u.Port() == `` {
if secure {
addr = u.Host + `:443`
} else {
addr = u.Host + `:80`
}
} else {
addr = u.Host
}
} else {
addr = opts.Addr
}
rawDialer, e := nk.Dialer(network, addr, nil)
Expand Down

0 comments on commit 9da6f6d

Please sign in to comment.