Пример #1
0
func run_server(basecfg *Config) (err error) {
	cfg, err := LoadServerConfig(basecfg)
	if err != nil {
		return
	}

	listener, err := net.Listen("tcp", cfg.Listen)
	if err != nil {
		return
	}

	listener, err = cryptconn.NewListener(listener, cfg.Cipher, cfg.Key)
	if err != nil {
		return
	}

	svr, err := msocks.NewServer(cfg.Auth, sutils.DefaultTcpDialer)
	if err != nil {
		return
	}

	if cfg.AdminIface != "" {
		mux := http.NewServeMux()
		NewMsocksManager(svr.SessionPool).Register(mux)
		go httpserver(cfg.AdminIface, mux)
	}

	return svr.Serve(listener)
}
Пример #2
0
func run_server(cfg *Config) (err error) {
	listener, err := net.Listen("tcp", cfg.Listen)
	if err != nil {
		return
	}

	listener, err = cryptconn.NewListener(
		listener, cfg.Cipher, cfg.Keyfile)
	if err != nil {
		return
	}

	s, err := msocks.NewService(cfg.Auth, sutils.DefaultTcpDialer)
	if err != nil {
		return
	}

	return s.Serve(listener)
}