mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-03 20:07:38 +03:00
Fix error message
This commit is contained in:
parent
26e13e7beb
commit
5bf1157e5a
4 changed files with 24 additions and 10 deletions
|
@ -53,7 +53,7 @@ func MainCmd() *cobra.Command {
|
|||
Short: "shadowsocks client as socks5 proxy, sing port",
|
||||
Version: sing.Version,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Run(flags)
|
||||
Run(cmd, flags)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ func NewLocalClient(flags *Flags) (*LocalClient, error) {
|
|||
|
||||
shadowClient, err := shadowsocks.NewClient(dialer, clientConfig)
|
||||
if err != nil {
|
||||
return nil, exceptions.Cause(err, "create shadowsocks")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := &LocalClient{
|
||||
|
@ -220,10 +220,12 @@ func (c *LocalClient) NewPacketConnection(conn socks.PacketConn, addr socksaddr.
|
|||
})
|
||||
}
|
||||
|
||||
func Run(flags *Flags) {
|
||||
func Run(cmd *cobra.Command, flags *Flags) {
|
||||
client, err := NewLocalClient(flags)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
logrus.StandardLogger().Log(logrus.FatalLevel, err, "\n\n")
|
||||
cmd.Help()
|
||||
os.Exit(1)
|
||||
}
|
||||
err = client.Start()
|
||||
if err != nil {
|
||||
|
|
|
@ -2,7 +2,6 @@ package shadowsocks
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/sagernet/sing/protocol/socks"
|
||||
"io"
|
||||
"net"
|
||||
"strconv"
|
||||
|
@ -12,6 +11,7 @@ import (
|
|||
"github.com/sagernet/sing/common/exceptions"
|
||||
"github.com/sagernet/sing/common/rw"
|
||||
"github.com/sagernet/sing/common/socksaddr"
|
||||
"github.com/sagernet/sing/protocol/socks"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -35,6 +35,16 @@ type Client struct {
|
|||
}
|
||||
|
||||
func NewClient(dialer *net.Dialer, config *ClientConfig) (*Client, error) {
|
||||
if config.Server == "" {
|
||||
return nil, exceptions.New("missing server address")
|
||||
}
|
||||
if config.ServerPort == 0 {
|
||||
return nil, exceptions.New("missing server port")
|
||||
}
|
||||
if config.Method == "" {
|
||||
return nil, exceptions.New("missing server method")
|
||||
}
|
||||
|
||||
cipher, err := CreateCipher(config.Method)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package socks
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/sagernet/sing/common"
|
||||
"github.com/sagernet/sing/common/buf"
|
||||
"github.com/sagernet/sing/common/socksaddr"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type PacketConn interface {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package system
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net"
|
||||
"net/netip"
|
||||
|
||||
"github.com/sagernet/sing/common"
|
||||
"github.com/sagernet/sing/common/exceptions"
|
||||
"github.com/sagernet/sing/common/socksaddr"
|
||||
"github.com/sagernet/sing/protocol/socks"
|
||||
"io"
|
||||
"net"
|
||||
"net/netip"
|
||||
)
|
||||
|
||||
type SocksHandler interface {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue