mirror of
https://github.com/bettercap/bettercap
synced 2025-07-07 21:42:06 -07:00
return more endpoint information with req.Client
This commit is contained in:
parent
ee809b6083
commit
2b4b58462c
1 changed files with 12 additions and 2 deletions
|
@ -8,10 +8,12 @@ import (
|
|||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/bettercap/bettercap/session"
|
||||
)
|
||||
|
||||
type JSRequest struct {
|
||||
Client string
|
||||
Client map[string]string
|
||||
Method string
|
||||
Version string
|
||||
Scheme string
|
||||
|
@ -43,8 +45,16 @@ func NewJSRequest(req *http.Request) *JSRequest {
|
|||
}
|
||||
}
|
||||
|
||||
client_ip := strings.Split(req.RemoteAddr, ":")[0]
|
||||
client_mac := ""
|
||||
client_alias := ""
|
||||
if endpoint := session.I.Lan.GetByIp(client_ip); endpoint != nil {
|
||||
client_mac = endpoint.HwAddress
|
||||
client_alias = endpoint.Alias
|
||||
}
|
||||
|
||||
jreq := &JSRequest{
|
||||
Client: strings.Split(req.RemoteAddr, ":")[0],
|
||||
Client: map[string]string{"IP": client_ip, "MAC": client_mac, "Alias": client_alias},
|
||||
Method: req.Method,
|
||||
Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor),
|
||||
Scheme: req.URL.Scheme,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue