]> Sergey Matveev's repositories - btrtrc.git/blobdiff - utp_libutp.go
Use the new firewall callback support in go-libutp
[btrtrc.git] / utp_libutp.go
index 94eba7cbc425d6821c7a2f7f767960783c3d192c..46ba3afb92fd55217f0a9c31e570f3a23e23c2c0 100644 (file)
@@ -6,11 +6,16 @@ import (
        "github.com/anacrolix/go-libutp"
 )
 
-func NewUtpSocket(network, addr string) (utpSocket, error) {
+func NewUtpSocket(network, addr string, fc firewallCallback) (utpSocket, error) {
        s, err := utp.NewSocket(network, addr)
        if s == nil {
                return nil, err
-       } else {
+       }
+       if err != nil {
                return s, err
        }
+       if fc != nil {
+               s.SetFirewallCallback(utp.FirewallCallback(fc))
+       }
+       return s, err
 }