(addr, password string, tcpTimeout, udpTimeout int)
| 31 | } |
| 32 | |
| 33 | func NewServer(addr, password string, tcpTimeout, udpTimeout int) (*Server, error) { |
| 34 | if err := limits.Raise(); err != nil { |
| 35 | Log(Error{"when": "try to raise system limits", "warning": err.Error()}) |
| 36 | } |
| 37 | s := &Server{ |
| 38 | Password: []byte(password), |
| 39 | Addr: addr, |
| 40 | TCPTimeout: tcpTimeout, |
| 41 | UDPTimeout: udpTimeout, |
| 42 | RunnerGroup: runnergroup.New(), |
| 43 | } |
| 44 | return s, nil |
| 45 | } |
| 46 | |
| 47 | func (s *Server) ListenAndServe() error { |
| 48 | addr, err := net.ResolveTCPAddr("tcp", s.Addr) |