Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jlatt/ergonomadic
base: b0a299c49c
...
head fork: jlatt/ergonomadic
compare: 4cee1ef909
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
8 README.md
@@ -3,3 +3,11 @@
## A Go IRC Daemon
Ergonomadic is an IRC daemon written from scratch in Go.
+
+### Why?
+
+I wanted to learn Go.
+
+### What's with the name?
+
+"Ergonomadic" is an anagram of "Go IRC Daemon".
View
7 ergonomadic.go
@@ -1,10 +1,13 @@
package main
import (
+ "flag"
"irc"
)
func main() {
- server := irc.NewServer()
- server.Listen(":6667")
+ name := flag.String("name", "localhost", "A name for the server")
+ listen := flag.String("listen", ":6667", "interface to listen on")
+ flag.Parse()
+ irc.NewServer(*name).Listen(*listen)
}
View
2  ergonomadic.sh
@@ -2,4 +2,4 @@
set -ex
export GOPATH="$(pwd)"
go install irc
-go run ergonomadic.go
+go run ergonomadic.go "$@"
View
5 src/irc/client.go
@@ -1,6 +1,7 @@
package irc
import (
+ "fmt"
"net"
"strings"
)
@@ -64,3 +65,7 @@ func (c *Client) Hostname() string {
}
return addr
}
+
+func (c *Client) UserHost() string {
+ return fmt.Sprintf("%s!%s@%s", c.nick, c.username, c.Hostname())
+}
View
4 src/irc/commands.go
@@ -64,8 +64,8 @@ func tryRegister(s *Server, c *Client) {
if (!c.registered && c.HasNick() && c.HasUser()) {
c.registered = true
c.send <- ReplyWelcome(c)
- c.send <- ReplyYourHost(c.Nick(), "irc.jlatt.com")
+ c.send <- ReplyYourHost(c.Nick(), s.name)
c.send <- ReplyCreated(c.Nick(), "2012/04/07")
- c.send <- ReplyMyInfo(c.Nick(), "irc.jlatt.com")
+ c.send <- ReplyMyInfo(c.Nick(), s.name)
}
}
View
4 src/irc/server.go
@@ -6,6 +6,7 @@ import (
)
type Server struct {
+ name string
ch chan *ClientMessage
nicks map[string]*Client
}
@@ -15,8 +16,9 @@ type ClientMessage struct {
message Message
}
-func NewServer() *Server {
+func NewServer(name string) *Server {
server := new(Server)
+ server.name = name
server.ch = make(chan *ClientMessage)
server.nicks = make(map[string]*Client)
go server.Receive()

No commit comments for this range

Something went wrong with that request. Please try again.