3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

Allow looking up usernames with ident on connection

This commit is contained in:
Daniel Oaks 2016-06-30 19:28:34 +10:00
parent 1d51bb450a
commit 19c2bb69fc
5 changed files with 38 additions and 0 deletions

View File

@ -16,6 +16,7 @@ Initial release of Oragono!
* Added YAML config file format. * Added YAML config file format.
* Added native SSL/TLS support (thanks to @edmand). * Added native SSL/TLS support (thanks to @edmand).
* Added ability to generate certificates from the command line. * Added ability to generate certificates from the command line.
* Can now lookup usernames with ident on client connection.
* We now advertise the [`RPL_ISUPPORT`](http://modern.ircdocs.horse/#rplisupport-005) numeric. * We now advertise the [`RPL_ISUPPORT`](http://modern.ircdocs.horse/#rplisupport-005) numeric.
* Parse new mode change syntax commonly used these days (i.e. `+h-ov dan dan dan`). * Parse new mode change syntax commonly used these days (i.e. `+h-ov dan dan dan`).
* User mode for clients connected via TLS (`+Z`). * User mode for clients connected via TLS (`+Z`).

View File

@ -7,11 +7,13 @@ package irc
import ( import (
"fmt" "fmt"
"log"
"net" "net"
"strconv" "strconv"
"time" "time"
"github.com/DanielOaks/girc-go/ircmsg" "github.com/DanielOaks/girc-go/ircmsg"
"github.com/DanielOaks/go-ident"
) )
const ( const (
@ -67,6 +69,35 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
if isTLS { if isTLS {
client.flags[TLS] = true client.flags[TLS] = true
} }
if server.checkIdent {
_, serverPortString, err := net.SplitHostPort(conn.LocalAddr().String())
serverPort, _ := strconv.Atoi(serverPortString)
if err != nil {
log.Fatal(err)
}
clientHost, clientPortString, err := net.SplitHostPort(conn.RemoteAddr().String())
clientPort, _ := strconv.Atoi(clientPortString)
if err != nil {
log.Fatal(err)
}
client.Notice("*** Looking up your username")
resp, err := ident.Query(clientHost, serverPort, clientPort)
if err == nil {
username := resp.Identifier
//TODO(dan): replace this with IsUsername/IsIRCName?
if Name(username).IsNickname() {
client.Notice("*** Found your username")
//TODO(dan): we do a bunch of user replacing in server.go userHandler, do we need that here?
client.username = Name(username)
// we don't need to updateNickMask here since nickMask is not used for anything yet
} else {
client.Notice("*** Got a malformed username, ignoring")
}
} else {
client.Notice("*** Could not find your username")
}
}
client.Touch() client.Touch()
go client.run() go client.run()

View File

@ -57,6 +57,7 @@ type Config struct {
Listen []string Listen []string
Wslisten string `yaml:"ws-listen"` Wslisten string `yaml:"ws-listen"`
TLSListeners map[string]*TLSListenConfig `yaml:"tls-listeners"` TLSListeners map[string]*TLSListenConfig `yaml:"tls-listeners"`
CheckIdent bool `yaml:"check-ident"`
Log string Log string
MOTD string MOTD string
ProxyAllowedFrom []string `yaml:"proxy-allowed-from"` ProxyAllowedFrom []string `yaml:"proxy-allowed-from"`

View File

@ -41,6 +41,7 @@ type Server struct {
whoWas *WhoWasList whoWas *WhoWasList
theaters map[Name][]byte theaters map[Name][]byte
isupport *ISupportList isupport *ISupportList
checkIdent bool
} }
var ( var (
@ -69,6 +70,7 @@ func NewServer(config *Config) *Server {
proxyAllowedFrom: config.Server.ProxyAllowedFrom, proxyAllowedFrom: config.Server.ProxyAllowedFrom,
whoWas: NewWhoWasList(100), whoWas: NewWhoWasList(100),
theaters: config.Theaters(), theaters: config.Theaters(),
checkIdent: config.Server.CheckIdent,
} }
if config.Server.MOTD != "" { if config.Server.MOTD != "" {

View File

@ -30,6 +30,9 @@ server:
key: tls.key key: tls.key
cert: tls.crt cert: tls.crt
# use ident protocol to get usernames
check-ident: true
# password to login to the server # password to login to the server
# generated using "oragono genpasswd" # generated using "oragono genpasswd"
#password: "" #password: ""