Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a555dbd563 | |||
| f076aeaeda | |||
| 1056493211 | |||
| ddcd65fa47 | |||
| d21b18fc75 | |||
| 53b72e0cb0 | |||
| 839dea016a | |||
| e235ee014e | |||
|
|
c54a271f17 | ||
|
|
264ee8c61c | ||
|
|
85e44756e3 | ||
|
|
e628bdcf91 | ||
|
|
f929379569 | ||
|
|
d5f331ec7c | ||
|
|
a609996484 | ||
|
|
0ec1c20d7e | ||
|
|
3cffacaa45 | ||
|
|
e0e5c742e3 | ||
|
|
7494823b07 | ||
|
|
7b2ab6642b | ||
|
|
f1051fbfc2 | ||
|
|
73a4134b18 | ||
|
|
962cc8dea0 | ||
|
|
9bde052d9d | ||
|
|
eabae2ce9b | ||
|
|
10f4db39cc |
4
.hgtags
4
.hgtags
@@ -1 +1,5 @@
|
||||
da295cede46d95848348292e04e54fa5a5713ae3 release-1.0.0
|
||||
34892054c34384edeafa2b04a483697d7d8a73a3 release-1.1.0
|
||||
3586b48a5abfdbdeef310f2e154b06f4d16d38bb release-1.2.0
|
||||
49dcc63e80e98f8c2ce3bb029fe0c41a6426678f release-1.2.1
|
||||
111d6e41507dd0f374860b936d18a651a7cb09ce release-1.2.2
|
||||
|
||||
6
TODO.txt
6
TODO.txt
@@ -4,6 +4,8 @@ BUGS
|
||||
|
||||
- /wrong/ password message shows up, but not if no password was given for a passworded nick
|
||||
|
||||
- tags not showing up in ncdc
|
||||
|
||||
|
||||
|
||||
WISHLIST
|
||||
@@ -13,10 +15,6 @@ WISHLIST
|
||||
|
||||
- automatic markdown bold/italic formatting
|
||||
|
||||
- support WHOIS
|
||||
|
||||
- respond to CTCP VERSION with the clienttag on behalf of other users
|
||||
|
||||
- support USERIP/KILL/KICK for ops
|
||||
|
||||
- use CTCP chat to support irc-special characters in chat messages (colon, newline)
|
||||
|
||||
@@ -8,6 +8,8 @@ TLS (SSL) support is not integrated. To host the IRC frontend over TLS, please u
|
||||
|
||||
This program uses some code from the AGPLv3 project https://github.com/eXeC64/Rosella , from which it inherits the Affero GPLv3 license. Anyone hosting a modified version of this software is required to release their changes under the terms of the AGPLv3.
|
||||
|
||||
Written in golang
|
||||
|
||||
Tags: nmdc, AGPLv3
|
||||
|
||||
=FEATURES=
|
||||
@@ -41,19 +43,21 @@ Tags: nmdc, AGPLv3
|
||||
|
||||
=COMPATIBILITY=
|
||||
|
||||
*This section was last updated on or around the release of 1.2.0. Current compatibility may differ.*
|
||||
|
||||
NMDC's smaller community has standardised around comparatively few protocol implementations by means of necessity. In comparison, there are a lot of IRC client implementations with slightly differing interpretations of the protocol.
|
||||
|
||||
Everything works:
|
||||
- Hexchat
|
||||
- Mango IRC
|
||||
- AndroIRC
|
||||
- Lite IRC
|
||||
- Mutter
|
||||
- Weechat
|
||||
- mIRC 7
|
||||
- HoloIRC (after version 4.1.0)
|
||||
|
||||
Usable, with bugs:
|
||||
- Lite IRC - The username and nickname fields must be identical
|
||||
- HoloIRC (4.1.0 and earlier) - Can't parse client tag, upstream bug https://github.com/tilal6991/HoloIRC/issues/140
|
||||
- AndChat - Duplicate usernames appear, upstream bug https://github.com/znc/znc/issues/424
|
||||
- Irssi - Ignorable warning "critical nicklist_set_host: assertion 'host != NULL' failed"
|
||||
@@ -63,6 +67,24 @@ Unusable:
|
||||
|
||||
=CHANGELOG=
|
||||
|
||||
2017-05-28 1.2.3
|
||||
- Fix a regression with userlist display on HexChat (other IRC client compatibility unknown)
|
||||
|
||||
2017-05-27 1.2.2
|
||||
- Update libnmdc to 0.14
|
||||
- Fix a crash that could occur if the server is scanned by a non-irc client
|
||||
|
||||
2016-11-29 1.2.1
|
||||
- Update libnmdc to 0.11
|
||||
- Fix an issue with -devel version tag in 1.2.0 release binaries
|
||||
|
||||
2016-08-27 1.2.0
|
||||
- Feature: Support WHOIS (display NMDC user's description + client software)
|
||||
- Feature: `-version` command-line option
|
||||
- Compatibility: Demote 'Lite IRC' to 'Usable with bugs' section
|
||||
- Update libnmdc to r9 (fix protocol issues)
|
||||
- Update golang to 1.7 (smaller binary size)
|
||||
|
||||
2016-05-10 1.1.0
|
||||
- Feature: Support renaming own client during connection (`/nick`)
|
||||
- Enhancement: Option to set Hub-Security nick (needed for initial CTCP, upgraded after upstream connection)
|
||||
|
||||
2
godist.sh
Normal file → Executable file
2
godist.sh
Normal file → Executable file
@@ -97,7 +97,7 @@ single_build() {
|
||||
|
||||
# Build.
|
||||
# GOARCH/GOOS supplied in function env
|
||||
go build -a -ldflags '-s -w' -o "$(pathfix "${tmpdir}/${local_bin_name}")"
|
||||
go build -a -ldflags "-s -w -X main.APP_VERSION=${version}" -o "$(pathfix "${tmpdir}/${local_bin_name}")"
|
||||
|
||||
# Sanitise.
|
||||
sanitise "${tmpdir}/${local_bin_name}"
|
||||
|
||||
13
main.go
13
main.go
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 The `nmdc-ircfrontend' author(s)
|
||||
Copyright (C) 2016-2017 The `nmdc-ircfrontend' author(s)
|
||||
Copyright (C) 2013 Harry Jeffery
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -20,22 +20,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"libnmdc"
|
||||
"log"
|
||||
"net"
|
||||
|
||||
"code.ivysaur.me/libnmdc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
ircAddress := flag.String("bind", ":6667", "The address:port to bind to and listen for clients on")
|
||||
dcAddress := flag.String("upstream", "127.0.0.1:411", "Upstream NMDC server")
|
||||
serverName := flag.String("servername", "nmdc-ircfrontend", "Server name displayed to clients")
|
||||
serverName := flag.String("servername", APP_NAME, "Server name displayed to clients")
|
||||
hubsec := flag.String("hubsecurity", "Hub-Security", "Nick used for administrative events")
|
||||
verbose := flag.Bool("verbose", false, "Display debugging information")
|
||||
autojoin := flag.Bool("autojoin", true, "Automatically join clients to the channel")
|
||||
version := flag.Bool("version", false, "Display version and exit")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if *version {
|
||||
log.Printf("%s version %s\n", APP_NAME, APP_VERSION)
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Listening on '%s'...", *ircAddress)
|
||||
if *autojoin {
|
||||
log.Printf("Clients will be automatically joined to the channel.")
|
||||
|
||||
81
server.go
81
server.go
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 The `nmdc-ircfrontend' author(s)
|
||||
Copyright (C) 2016-2017 The `nmdc-ircfrontend' author(s)
|
||||
Copyright (C) 2013 Harry Jeffery
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -22,13 +22,14 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"libnmdc"
|
||||
"log"
|
||||
"net"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"code.ivysaur.me/libnmdc"
|
||||
)
|
||||
|
||||
type ClientState int
|
||||
@@ -39,6 +40,30 @@ const (
|
||||
CSJoined
|
||||
)
|
||||
|
||||
type Quirks struct {
|
||||
SendNamesOnWho bool
|
||||
}
|
||||
|
||||
func DefaultQuirks() Quirks {
|
||||
return Quirks{
|
||||
SendNamesOnWho: false,
|
||||
}
|
||||
}
|
||||
|
||||
func HexChatQuirks() Quirks {
|
||||
return Quirks{
|
||||
SendNamesOnWho: true,
|
||||
}
|
||||
}
|
||||
|
||||
func GetQuirksForClient(ver string) Quirks {
|
||||
if strings.Contains(ver, "HexChat") {
|
||||
return HexChatQuirks()
|
||||
} else {
|
||||
return DefaultQuirks()
|
||||
}
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
name string
|
||||
motd string
|
||||
@@ -58,6 +83,8 @@ type Server struct {
|
||||
recievedFirstServerMessage bool
|
||||
recievedCtcpVersion bool
|
||||
nickChangeAttempt int
|
||||
|
||||
quirks Quirks
|
||||
}
|
||||
|
||||
func NewServer(name string, upstream libnmdc.HubAddress, conn net.Conn) *Server {
|
||||
@@ -76,6 +103,7 @@ func NewServer(name string, upstream libnmdc.HubAddress, conn net.Conn) *Server
|
||||
SkipAutoReconnect: true,
|
||||
},
|
||||
upstreamCloser: make(chan struct{}, 1),
|
||||
quirks: DefaultQuirks(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +141,7 @@ func (s *Server) RunWorker() {
|
||||
}
|
||||
|
||||
// If this was a /timeout/, send a KA and continue.
|
||||
if libnmdc.CheckIsNetTimeout(err) {
|
||||
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
|
||||
s.writeClient("PING :" + s.name)
|
||||
continue
|
||||
}
|
||||
@@ -132,12 +160,12 @@ func (s *Server) RunWorker() {
|
||||
|
||||
// Client sent a command
|
||||
fields := strings.Fields(string(line))
|
||||
if len(fields) < 1 {
|
||||
if len(fields) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if strings.HasPrefix(fields[0], ":") {
|
||||
fields = fields[1:]
|
||||
fields[0] = fields[0][1:]
|
||||
}
|
||||
|
||||
s.handleCommand(strings.ToUpper(fields[0]), fields[1:])
|
||||
@@ -240,7 +268,7 @@ func (s *Server) upstreamWorker() {
|
||||
// description change - no relevance for IRC users
|
||||
|
||||
case libnmdc.EVENT_CONNECTION_STATE_CHANGED:
|
||||
s.postGeneralMessageInRoom("* Upstream: " + hubEvent.StateChange.Format())
|
||||
s.postGeneralMessageInRoom("* Upstream: " + hubEvent.StateChange.String())
|
||||
|
||||
if hubEvent.StateChange == libnmdc.CONNECTIONSTATE_CONNECTED {
|
||||
s.sendNames() // delay doing this until now
|
||||
@@ -438,6 +466,7 @@ func (s *Server) handleRegisteredCommand(command string, args []string) {
|
||||
versionString := message[9:]
|
||||
versionString = versionString[:len(versionString)-1]
|
||||
s.SetClientSoftwareVersion(versionString)
|
||||
s.quirks = GetQuirksForClient(versionString)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -635,6 +664,10 @@ func (s *Server) handleJoinedCommand(command string, args []string) {
|
||||
// s.sendWho(args[0])
|
||||
// s.sendNames() // fixes hexchat, but andchat always sends WHO /immediately/ after NAMES end, causing an infinite loop
|
||||
|
||||
if s.quirks.SendNamesOnWho {
|
||||
s.sendNames()
|
||||
}
|
||||
|
||||
case "MODE":
|
||||
if len(args) < 1 {
|
||||
s.reply(errMoreArgs)
|
||||
@@ -657,6 +690,35 @@ func (s *Server) handleJoinedCommand(command string, args []string) {
|
||||
|
||||
return
|
||||
|
||||
case "WHOIS":
|
||||
if len(args) < 1 {
|
||||
s.reply(errMoreArgs)
|
||||
return
|
||||
}
|
||||
|
||||
// WHOIS [target] nick[,nick2[,nick...]]
|
||||
nicklist := args[0] // Assume WHOIS ${nick} only,
|
||||
if len(args) >= 2 {
|
||||
nicklist = args[1] // It was WHOIS ${target} ${nick} instead
|
||||
}
|
||||
|
||||
for _, targetnick := range strings.Split(nicklist, ",") {
|
||||
// tell the client something about it
|
||||
// The protocol does ostensibly support wildcard WHOIS, but we don't (yet)
|
||||
s.upstream.Users(func(u *map[string]libnmdc.UserInfo) error {
|
||||
for nick, nickinfo := range *u {
|
||||
if nick == targetnick {
|
||||
s.reply(rplWhoisUser, nick, nickinfo.Description+" <"+nickinfo.ClientTag+" V:"+nickinfo.ClientVersion+">")
|
||||
if nickinfo.IsOperator {
|
||||
s.reply(rplWhoisOperator, nick)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
s.reply(rplEndOfWhois)
|
||||
}
|
||||
|
||||
default:
|
||||
s.reply(errUnknownCommand, command)
|
||||
}
|
||||
@@ -815,6 +877,13 @@ func (s *Server) reply(code replyCode, args ...string) {
|
||||
case rplPong:
|
||||
s.writeClient(fmt.Sprintf(":%s PONG %s %s", s.name, s.clientNick(), args[0]))
|
||||
|
||||
case rplWhoisUser:
|
||||
s.writeClient(fmt.Sprintf(":%s 311 %s %s %s %s * :%s", s.name, args[0], args[0], args[0], s.name, args[1])) // caller should supply nick,description
|
||||
case rplWhoisOperator:
|
||||
s.writeClient(fmt.Sprintf(":%s 313 %s :is an IRC operator", s.name, args[0]))
|
||||
case rplEndOfWhois:
|
||||
s.writeClient(fmt.Sprintf(":%s 318 :End of WHOIS list", s.name))
|
||||
|
||||
case errMoreArgs:
|
||||
s.writeClient(fmt.Sprintf(":%s 461 %s :Not enough params", s.name, s.clientNick()))
|
||||
case errNoNick:
|
||||
|
||||
10
typedefs.go
10
typedefs.go
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 The `nmdc-ircfrontend' author(s)
|
||||
Copyright (C) 2016-2017 The `nmdc-ircfrontend' author(s)
|
||||
Copyright (C) 2013 Harry Jeffery
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -18,8 +18,11 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var (
|
||||
APP_VERSION = "1.x.x-dev" // overridden with build ldflags
|
||||
)
|
||||
|
||||
const (
|
||||
APP_VERSION = "1.1.0"
|
||||
APP_NAME = "nmdc-ircfrontend"
|
||||
BLESSED_CHANNEL = "#chat" // must be lowercase
|
||||
BLESSED_CHANNEL_MODE = "n" // means that you have to be in the channel to chat, but that's it
|
||||
@@ -56,6 +59,9 @@ const (
|
||||
rplMOTD
|
||||
rplEndOfMOTD
|
||||
rplPong
|
||||
rplWhoisUser
|
||||
rplWhoisOperator
|
||||
rplEndOfWhois
|
||||
errMoreArgs
|
||||
errNoNick
|
||||
errInvalidNick
|
||||
|
||||
Reference in New Issue
Block a user