From 529d834815a4a102fecb0c6538aafea93491dedb Mon Sep 17 00:00:00 2001 From: evilsocket Date: Thu, 8 Feb 2018 01:03:31 +0100 Subject: [PATCH] new: keeping track of interface index --- net/endpoint.go | 1 + net/net.go | 1 + session/session.go | 1 + 3 files changed, 3 insertions(+) diff --git a/net/endpoint.go b/net/endpoint.go index 2f607a29..997d6b90 100644 --- a/net/endpoint.go +++ b/net/endpoint.go @@ -11,6 +11,7 @@ import ( type OnHostResolvedCallback func(e *Endpoint) type Endpoint struct { + Index int `json:"-"` IP net.IP `json:"-"` Net *net.IPNet `json:"-"` IPv6 net.IP `json:"-"` diff --git a/net/net.go b/net/net.go index 5587d88a..3bfaa9bb 100644 --- a/net/net.go +++ b/net/net.go @@ -94,6 +94,7 @@ func FindInterface(name string) (*Endpoint, error) { if len(e.HW) == 0 { return nil, fmt.Errorf("Could not detect interface hardware address.") } + e.Index = iface.Index return e, nil } } diff --git a/session/session.go b/session/session.go index 6337e8fb..1d7cd516 100644 --- a/session/session.go +++ b/session/session.go @@ -201,6 +201,7 @@ func (s *Session) Start() error { s.Env.Set(PromptVariable, DefaultPrompt) + s.Env.Set("iface.index", fmt.Sprintf("%d", s.Interface.Index)) s.Env.Set("iface.name", s.Interface.Name()) s.Env.Set("iface.ipv4", s.Interface.IpAddress) s.Env.Set("iface.ipv6", s.Interface.Ip6Address)