本文整理匯總了Golang中spool-mock/client.Conn.Close方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.Close方法的具體用法?Golang Conn.Close怎麽用?Golang Conn.Close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類spool-mock/client.Conn
的用法示例。
在下文中一共展示了Conn.Close方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: req
func req(conn *client.Conn) {
conn.Send("200 StoreD")
for {
tok, e := conn.ReadLine()
if e != nil {
fmt.Println(fmt.Sprintf("WARN: C(%s): %s", conn.RemoteAddr(), e.Error()))
break
}
cmd := strings.ToUpper(tok[0])
if cmd == "QUIT" {
Quit(conn, tok)
break
} else if cmd == "ARTICLE" {
Article(conn, tok)
} else if cmd == "HEAD" {
Head(conn, tok)
} else if cmd == "BODY" {
Body(conn, tok)
} else if cmd == "STAT" {
Stat(conn, tok)
} else if cmd == "AUTHINFO" {
sub := strings.ToUpper(tok[1])
if sub == "USER" {
conn.User = tok[2]
conn.Send("381 Need more.")
} else if sub == "PASS" {
if tok[2] == "test" {
conn.Send("281 Authentication accepted.")
}
}
} else if cmd == "GROUP" {
Group(conn, tok)
} else if cmd == "NOOP" {
conn.Send("500 Unsupported.")
} else if cmd == "IHAVE" {
PostArticle(conn, tok)
} else if cmd == "POST" {
if e := conn.Send("340 Start posting."); e != nil {
conn.Send("437 Start failed.")
}
br := bufio.NewReader(conn.GetReader())
if _, e := io.Copy(ioutil.Discard, dotreader.New(br)); e != nil {
conn.Send("437 Failed reading body")
return
}
if e := conn.Send("240 Posted "); e != nil {
conn.Send("437 Failed storing.")
}
} else if cmd == "XOVER" {
Xover(conn, tok)
} else if cmd == "XHDR" {
Xhdr(conn, tok)
} else if cmd == "LIST" {
List(conn, tok)
} else if cmd == "DATE" {
Date(conn, tok)
} else {
Unsupported(conn, tok)
break
}
}
conn.Close()
if config.Verbose {
fmt.Println(fmt.Sprintf("C(%s) Closed", conn.RemoteAddr()))
}
}
示例2: read
func read(conn *client.Conn, msgid string, msgtype string) {
var code, msgtop string
head := true
body := true
if msgid == "<[email protected]>" && conn.User != "spool" {
conn.Send("430 Article not found.")
return
}
if msgid == "<[email protected]>" {
conn.Send("430 Article not found.")
return
}
if msgid[0] == '<' {
msgtop = "0 " + msgid
} else {
msgtop = msgid + " " + "<[email protected]>"
}
if msgtype == "ARTICLE" {
code = "220"
} else if msgtype == "HEAD" {
code = "221"
body = false
} else if msgtype == "BODY" {
code = "222"
head = false
} else {
panic("Should not get here")
}
if msgid == "<[email protected]>" || msgid == "123" {
conn.Send("500 msgid means fivehundred err")
return
}
// fake some timeouts here
if msgid == "<[email protected]>" {
time.Sleep(time.Second * 180)
}
if msgid == "<[email protected]>" {
time.Sleep(time.Second * 20)
}
var raw string
if head {
raw += `Path: asg009!abp002.ams.xsnews.nl!abuse.newsxs.nl!not-for-mail
From: Zinitzio <x8F4zpNLByt8Vhh1hyFBTcarWqKeqTszySrxYJUNrGyj64VA761YahKczcyROsOv.N[email protected]47a00b01.16110764.10.1443172883.1.NL.v8r0DMvyrMxvrV9wjB9RklWe-p-p1ZChfS4lxGsMNtRWMbyLXZonEJ6Lp3usHDsLnG>
Subject: Mkv Tool Nix 8.4.0 NL | Zgp
Newsgroups: free.pt
Message-ID: <[email protected]>
X-Newsreader: Spotnet 2.0.0.114
X-XML: <Spotnet><Posting><Key>7</Key><Created>1443172883</Created><Poster>Zinitzio</Poster><Tag>Zgp</Tag><Title>Mkv Tool Nix 8.4.0 NL</Title><Description>Iedere Mkv (x264) film heeft meerdere sporen. Met dit programma kun je sporen verwijderen of toevoegen. Heb je een film zonder ondertitel dan kun je die makkelijk toevoegen.[br][br]In deze spot zitten de volgende onderdelen:[br][br]Mkv Tool Nix 8.4.0</Description><Image Width='350' Height='350'><Segment>[email protected]</Segment></Image><Size>16110764</Size><Category>04<Sub>04a00</Sub><Sub>04b01</Sub></Category><NZB><Segment>[email protected]</Segment></NZB></Posting></Spotnet>
X-XML-Signature: mMXtDVvEzuAz5soJzKcpsd042VQY2M306o418-pOYtLIxv7DN5lDzAO3rB3EakfZT
X-User-Key: <RSAKeyValue><Modulus>x8F4zpNLByt8Vhh1hyFBTcarWqKeqTszySrxYJUNrGyj64VA761YahKczcyROsOv</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>
X-User-Signature: N5UyksLragucHTY7hXbIf3OraQSwtjjJX6PcYubvlsh6oPDUGuY1j0b4Z7i6xnio
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Complaints-To: [email protected]
Organization: Newsxs
Date: Fri, 25 Sep 2015 11:21:23 +0200
Lines: 5
NNTP-Posting-Date: Fri, 25 Sep 2015 11:21:23 +0200`
}
if head && body {
raw += "\n\n"
}
if body {
raw += `Iedere Mkv (x264) film heeft meerdere sporen. Met dit programma kun je sporen verwijderen of toevoegen. Heb je een film zonder ondertitel dan kun je die makkelijk toevoegen.
In deze spot zitten de volgende onderdelen:
Mkv Tool Nix 8.4.0`
}
if msgid == "<[email protected]>" {
raw = strings.Replace(raw, "X-Newsreader: Spotnet 2.0.0.114", "Header-Key: REPLACEME", 1)
}
raw = strings.Replace(raw, "\n", "\r\n", -1)
if msgid == "<[email protected]>" {
raw = strings.Replace(
raw,
"Fri, 25 Sep 2015 11:21:23 +0200",
time.Now().Format("Mon, 2 Jan 2006 15:04:05 -0700"),
1,
)
}
conn.Send(code + " " + msgtop)
if msgid == "<[email protected]>" || msgid == "124" {
// fake a broken
conn.Send(raw[0:50])
conn.Close()
} else {
conn.Send(raw)
}
conn.Send("\r\n.") // additional \r\n auto-added
if msgid == "<[email protected]>" || msgid == "500" {
//.........這裏部分代碼省略.........