Commit 0621514d authored by Johannes Schilling's avatar Johannes Schilling
Browse files

use hex instead of base64 as ident response

contrary to RFC1413, some IRC networks cannot handle special characters
in the ident response (e.g. '+' on freenode)

increase the length of sent response from 8 to 12 to make up for the
lost character range (of which many popular networks only use 10)
parent cf00784b
......@@ -29,7 +29,7 @@ import (
"bufio"
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"flag"
"fmt"
"io/ioutil"
......@@ -41,7 +41,7 @@ import (
)
const (
MacBytes = 8 // how many bytes of the hash we send in the ident response
MacBytes = 12 // how many bytes of the hash we send in the ident response
)
func main() {
......@@ -142,10 +142,10 @@ func handleIdentRequest(c net.Conn, hmacSecret []byte) error {
// response (i.e. reverse lookup)
mac := hmac.New(sha256.New, hmacSecret)
fmt.Fprintln(mac, uid)
macB64 := base64.StdEncoding.EncodeToString(mac.Sum(nil))
macHex := hex.EncodeToString(mac.Sum(nil))
_, err = fmt.Fprintf(c, "%d,%d:USERID:OTHER:%s\n",
lPort, rPort, macB64[:MacBytes])
lPort, rPort, macHex[:MacBytes])
if err != nil {
return err
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment