本文整理汇总了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" {
//.........这里部分代码省略.........