X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fsp.go;h=e8e477cff9da8b5aa83b5ef75697142bd5c28cb8;hb=0ed43747344437800094782e78313b1c41c2cc1c;hp=4db358742a17b1f584aa102ac853a1c6386c6d13;hpb=128618d02d84d08164060f14e7fdd3b87e491fcb;p=nncp.git diff --git a/src/sp.go b/src/sp.go index 4db3587..e8e477c 100644 --- a/src/sp.go +++ b/src/sp.go @@ -27,6 +27,7 @@ import ( "os" "path/filepath" "sort" + "strconv" "sync" "time" @@ -39,6 +40,7 @@ const ( MaxSPSize = 1<<16 - 256 PartSuffix = ".part" SPHeadOverhead = 4 + CfgDeadline = "NNCPDEADLINE" ) type MTHAndOffset struct { @@ -132,6 +134,14 @@ type ConnDeadlined interface { } func init() { + if v := os.Getenv(CfgDeadline); v != "" { + i, err := strconv.Atoi(v) + if err != nil { + log.Fatalln("Can not convert", CfgDeadline, "to integer:", err) + } + DefaultDeadline = time.Duration(i) * time.Second + } + var buf bytes.Buffer spHead := SPHead{Type: SPTypeHalt} if _, err := xdr.Marshal(&buf, spHead); err != nil {