mirror of
https://github.com/bettercap/bettercap
synced 2025-07-11 15:46:59 -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"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/bettercap/bettercap/session"
|
||||||
)
|
)
|
||||||
|
|
||||||
type JSRequest struct {
|
type JSRequest struct {
|
||||||
Client string
|
Client map[string]string
|
||||||
Method string
|
Method string
|
||||||
Version string
|
Version string
|
||||||
Scheme 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{
|
jreq := &JSRequest{
|
||||||
Client: strings.Split(req.RemoteAddr, ":")[0],
|
Client: map[string]string{"IP": client_ip, "MAC": client_mac, "Alias": client_alias},
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor),
|
Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor),
|
||||||
Scheme: req.URL.Scheme,
|
Scheme: req.URL.Scheme,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue