2 Commits

Author SHA1 Message Date
James Mills
d3fd6ec764 Added support for network name and RPL_WELCOME to display network name 2017-11-25 15:20:54 -08:00
James Mills
2fef0feb5a Added Travis CI config and fixed some broken tests (#12) 2017-11-24 22:48:16 -08:00
5 changed files with 47 additions and 8 deletions

8
.travis.yml Normal file
View File

@@ -0,0 +1,8 @@
language: go
sudo: false
go:
- tip
before_install:
- go get github.com/mattn/goveralls
script:
- $HOME/gopath/bin/goveralls -service=travis-ci

View File

@@ -33,6 +33,10 @@ type Config struct {
sync.Mutex
filename string
Network struct {
Name string
}
Server struct {
PassConfig `yaml:",inline"`
Listen []string
@@ -97,6 +101,10 @@ func LoadConfig(filename string) (config *Config, err error) {
config.filename = filename
if config.Network.Name == "" {
return nil, errors.New("Network name missing")
}
if config.Server.Name == "" {
return nil, errors.New("Server name missing")
}

View File

@@ -173,8 +173,12 @@ func RplCap(client *Client, subCommand CapSubCommand, arg interface{}) string {
// numeric replies
func (target *Client) RplWelcome() {
target.NumericReply(RPL_WELCOME,
":Welcome to the Internet Relay Network %s", target.Id())
target.NumericReply(
RPL_WELCOME,
":Welcome to the %s Internet Relay Network %s",
target.server.Network(),
target.Id(),
)
}
func (target *Client) RplYourHost() {
@@ -260,14 +264,22 @@ func (target *Client) RplWhois(client *Client) {
}
func (target *Client) RplWhoisUser(client *Client) {
if client.flags[SecureConn]: {
clientHost := client.hostname
var clientHost Name
if client.flags[SecureConn] {
clientHost = client.hostname
} else {
clientHost := 'SECURED'
clientHost = NewName("SECURED")
}
target.NumericReply(RPL_WHOISUSER,
"%s %s %s * :%s", client.Nick(), client.username, clientHost,
client.realname)
target.NumericReply(
RPL_WHOISUSER,
"%s %s %s * :%s",
client.Nick(),
client.username,
clientHost,
client.realname,
)
}
func (target *Client) RplWhoisOperator(client *Client) {

View File

@@ -37,6 +37,7 @@ type Server struct {
idle chan *Client
motdFile string
name Name
network Name
description string
newConns chan net.Conn
operators map[Name][]byte
@@ -63,6 +64,7 @@ func NewServer(config *Config) *Server {
idle: make(chan *Client),
motdFile: config.Server.MOTD,
name: NewName(config.Server.Name),
network: NewName(config.Network.Name),
description: config.Server.Description,
newConns: make(chan net.Conn),
operators: config.Operators(),
@@ -314,6 +316,7 @@ func (s *Server) Rehash() error {
s.motdFile = s.config.Server.MOTD
s.name = NewName(s.config.Server.Name)
s.network = NewName(s.config.Network.Name)
s.description = s.config.Server.Description
s.operators = s.config.Operators()
@@ -324,6 +327,10 @@ func (s *Server) Id() Name {
return s.name
}
func (s *Server) Network() Name {
return s.network
}
func (s *Server) String() string {
return s.name.String()
}

View File

@@ -1,3 +1,7 @@
network:
# network name
name: Local
server:
# server name
name: localhost.localdomain