(addr, domain, path, to string, tcpTimeout, udpTimeout int)
| 41 | } |
| 42 | |
| 43 | func NewDOHServer(addr, domain, path, to string, tcpTimeout, udpTimeout int) (*DOHServer, error) { |
| 44 | if err := limits.Raise(); err != nil { |
| 45 | Log(Error{"when": "try to raise system limits", "warning": err.Error()}) |
| 46 | } |
| 47 | s := &DOHServer{ |
| 48 | Addr: addr, |
| 49 | Domain: domain, |
| 50 | Path: path, |
| 51 | } |
| 52 | if !strings.HasPrefix(to, "https://") { |
| 53 | s.DNSClient = &DNSClient{Server: to} |
| 54 | } |
| 55 | if strings.HasPrefix(to, "https://") { |
| 56 | c, err := NewDOHClient(to) |
| 57 | if err != nil { |
| 58 | return nil, err |
| 59 | } |
| 60 | s.DOHClient = c |
| 61 | } |
| 62 | return s, nil |
| 63 | } |
| 64 | |
| 65 | func (s *DOHServer) ListenAndServe() error { |
| 66 | r := mux.NewRouter() |
no test coverage detected