Commit 95526fae authored by bensinober's avatar bensinober
Browse files

Add reverse lookup as option 1 for mapping

parent 159cf362
......@@ -9,6 +9,7 @@ import (
"io/ioutil"
"log"
"mime/multipart"
"net"
"net/http"
"os"
"os/exec"
......@@ -75,12 +76,22 @@ func main() {
}
var printer Printer
// First try by userid, then by origin IP
if prUserId != "" {
printer = mapping[prUserId]
// first do reverse lookup for ip addr matching name in mapping
names, _ := net.LookupAddr(prOrigin)
for _, name := range names {
fmt.Println(name)
if v, ok := mapping[name]; ok {
printer = v
}
}
// else try userid and finally ip
if printer.Name == "" {
printer = mapping[prOrigin]
if prUserId != "" {
printer = mapping[prUserId]
}
if printer.Name == "" {
printer = mapping[prOrigin]
}
}
if printer.Name == "" {
......
Markdown is supported
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