continuous-integration/drone Build is failing
Migrate the workspace to React and Ant Design, improve account forms and responsive layouts, support outbound diagnostics and SSH fingerprint confirmation, and persist the management startup port. Preserve database migrations, remove S3 settings storage, and improve gateway audit handling.
27 lines
648 B
Go
27 lines
648 B
Go
package outbound
|
|
|
|
import (
|
|
"context"
|
|
"linkport/internal/model"
|
|
"net"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
func TestSOCKS5(ctx context.Context, profile model.Outbound) error {
|
|
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
|
defer cancel()
|
|
connection, err := (&net.Dialer{}).DialContext(ctx, "tcp", net.JoinHostPort(profile.Host, strconv.Itoa(profile.Port)))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer connection.Close()
|
|
stop := context.AfterFunc(ctx, func() { connection.Close() })
|
|
defer stop()
|
|
deadline, _ := ctx.Deadline()
|
|
if err = connection.SetDeadline(deadline); err != nil {
|
|
return err
|
|
}
|
|
return negotiateSOCKS5(ctx, connection, profile)
|
|
}
|