mirror of
https://github.com/Snawoot/opera-proxy.git
synced 2025-09-15 17:59:56 +00:00
fmt; fixed IP address dialer option for seclient
This commit is contained in:
parent
9a35f96795
commit
1c4a8991bc
3 changed files with 58 additions and 23 deletions
31
fixed.go
Normal file
31
fixed.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
)
|
||||
|
||||
type FixedDialer struct {
|
||||
fixedAddress string
|
||||
next ContextDialer
|
||||
}
|
||||
|
||||
func NewFixedDialer(address string, next ContextDialer) *FixedDialer {
|
||||
return &FixedDialer{
|
||||
fixedAddress: address,
|
||||
next: next,
|
||||
}
|
||||
}
|
||||
|
||||
func (d *FixedDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
_, port, err := net.SplitHostPort(address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return d.next.DialContext(ctx, network, net.JoinHostPort(d.fixedAddress, port))
|
||||
}
|
||||
|
||||
func (d *FixedDialer) Dial(network, address string) (net.Conn, error) {
|
||||
return d.DialContext(context.Background(), network, address)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue