mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-07-19 21:08:40 +08:00
tailscale: Expose more peer info fields
This commit is contained in:
parent
9afbd45d4b
commit
3bc481a845
@ -41,12 +41,16 @@ type TailscalePeer struct {
|
||||
DNSName string
|
||||
OS string
|
||||
TailscaleIPs []string
|
||||
SSHHostKeys []string
|
||||
Online bool
|
||||
ExitNode bool
|
||||
ExitNodeOption bool
|
||||
ShareeNode bool
|
||||
Expired bool
|
||||
Active bool
|
||||
RxBytes int64
|
||||
TxBytes int64
|
||||
UserID int64
|
||||
KeyExpiry int64
|
||||
LastSeen int64
|
||||
}
|
||||
|
||||
@ -1397,13 +1397,17 @@ func tailscalePeerToProto(peer *adapter.TailscalePeer) *TailscalePeer {
|
||||
DnsName: peer.DNSName,
|
||||
Os: peer.OS,
|
||||
TailscaleIPs: peer.TailscaleIPs,
|
||||
SshHostKeys: peer.SSHHostKeys,
|
||||
Online: peer.Online,
|
||||
ExitNode: peer.ExitNode,
|
||||
ExitNodeOption: peer.ExitNodeOption,
|
||||
ShareeNode: peer.ShareeNode,
|
||||
Expired: peer.Expired,
|
||||
Active: peer.Active,
|
||||
RxBytes: peer.RxBytes,
|
||||
TxBytes: peer.TxBytes,
|
||||
KeyExpiry: peer.KeyExpiry,
|
||||
LastSeen: peer.LastSeen,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2482,6 +2482,10 @@ type TailscalePeer struct {
|
||||
TxBytes int64 `protobuf:"varint,10,opt,name=txBytes,proto3" json:"txBytes,omitempty"`
|
||||
KeyExpiry int64 `protobuf:"varint,11,opt,name=keyExpiry,proto3" json:"keyExpiry,omitempty"`
|
||||
StableID string `protobuf:"bytes,12,opt,name=stableID,proto3" json:"stableID,omitempty"`
|
||||
Expired bool `protobuf:"varint,13,opt,name=expired,proto3" json:"expired,omitempty"`
|
||||
SshHostKeys []string `protobuf:"bytes,14,rep,name=sshHostKeys,proto3" json:"sshHostKeys,omitempty"`
|
||||
ShareeNode bool `protobuf:"varint,15,opt,name=shareeNode,proto3" json:"shareeNode,omitempty"`
|
||||
LastSeen int64 `protobuf:"varint,16,opt,name=lastSeen,proto3" json:"lastSeen,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@ -2600,6 +2604,34 @@ func (x *TailscalePeer) GetStableID() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *TailscalePeer) GetExpired() bool {
|
||||
if x != nil {
|
||||
return x.Expired
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *TailscalePeer) GetSshHostKeys() []string {
|
||||
if x != nil {
|
||||
return x.SshHostKeys
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *TailscalePeer) GetShareeNode() bool {
|
||||
if x != nil {
|
||||
return x.ShareeNode
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *TailscalePeer) GetLastSeen() int64 {
|
||||
if x != nil {
|
||||
return x.LastSeen
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type TailscalePingRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
EndpointTag string `protobuf:"bytes,1,opt,name=endpointTag,proto3" json:"endpointTag,omitempty"`
|
||||
@ -3031,7 +3063,7 @@ const file_daemon_started_service_proto_rawDesc = "" +
|
||||
"\tloginName\x18\x02 \x01(\tR\tloginName\x12 \n" +
|
||||
"\vdisplayName\x18\x03 \x01(\tR\vdisplayName\x12$\n" +
|
||||
"\rprofilePicURL\x18\x04 \x01(\tR\rprofilePicURL\x12+\n" +
|
||||
"\x05peers\x18\x05 \x03(\v2\x15.daemon.TailscalePeerR\x05peers\"\xdb\x02\n" +
|
||||
"\x05peers\x18\x05 \x03(\v2\x15.daemon.TailscalePeerR\x05peers\"\xd3\x03\n" +
|
||||
"\rTailscalePeer\x12\x1a\n" +
|
||||
"\bhostName\x18\x01 \x01(\tR\bhostName\x12\x18\n" +
|
||||
"\adnsName\x18\x02 \x01(\tR\adnsName\x12\x0e\n" +
|
||||
@ -3045,7 +3077,13 @@ const file_daemon_started_service_proto_rawDesc = "" +
|
||||
"\atxBytes\x18\n" +
|
||||
" \x01(\x03R\atxBytes\x12\x1c\n" +
|
||||
"\tkeyExpiry\x18\v \x01(\x03R\tkeyExpiry\x12\x1a\n" +
|
||||
"\bstableID\x18\f \x01(\tR\bstableID\"P\n" +
|
||||
"\bstableID\x18\f \x01(\tR\bstableID\x12\x18\n" +
|
||||
"\aexpired\x18\r \x01(\bR\aexpired\x12 \n" +
|
||||
"\vsshHostKeys\x18\x0e \x03(\tR\vsshHostKeys\x12\x1e\n" +
|
||||
"\n" +
|
||||
"shareeNode\x18\x0f \x01(\bR\n" +
|
||||
"shareeNode\x12\x1a\n" +
|
||||
"\blastSeen\x18\x10 \x01(\x03R\blastSeen\"P\n" +
|
||||
"\x14TailscalePingRequest\x12 \n" +
|
||||
"\vendpointTag\x18\x01 \x01(\tR\vendpointTag\x12\x16\n" +
|
||||
"\x06peerIP\x18\x02 \x01(\tR\x06peerIP\"\xcf\x01\n" +
|
||||
|
||||
@ -317,6 +317,10 @@ message TailscalePeer {
|
||||
int64 txBytes = 10;
|
||||
int64 keyExpiry = 11;
|
||||
string stableID = 12;
|
||||
bool expired = 13;
|
||||
repeated string sshHostKeys = 14;
|
||||
bool shareeNode = 15;
|
||||
int64 lastSeen = 16;
|
||||
}
|
||||
|
||||
message TailscalePingRequest {
|
||||
|
||||
@ -58,19 +58,27 @@ type TailscalePeer struct {
|
||||
DNSName string
|
||||
OS string
|
||||
tailscaleIPs []string
|
||||
sshHostKeys []string
|
||||
Online bool
|
||||
ExitNode bool
|
||||
ExitNodeOption bool
|
||||
ShareeNode bool
|
||||
Expired bool
|
||||
Active bool
|
||||
RxBytes int64
|
||||
TxBytes int64
|
||||
KeyExpiry int64
|
||||
LastSeen int64
|
||||
}
|
||||
|
||||
func (p *TailscalePeer) TailscaleIPs() StringIterator {
|
||||
return newIterator(p.tailscaleIPs)
|
||||
}
|
||||
|
||||
func (p *TailscalePeer) SSHHostKeys() StringIterator {
|
||||
return newIterator(p.sshHostKeys)
|
||||
}
|
||||
|
||||
type TailscaleStatusHandler interface {
|
||||
OnStatusUpdate(status *TailscaleStatusUpdate)
|
||||
OnError(message string)
|
||||
@ -127,12 +135,16 @@ func tailscalePeerFromGRPC(peer *daemon.TailscalePeer) *TailscalePeer {
|
||||
DNSName: peer.DnsName,
|
||||
OS: peer.Os,
|
||||
tailscaleIPs: peer.TailscaleIPs,
|
||||
sshHostKeys: peer.SshHostKeys,
|
||||
Online: peer.Online,
|
||||
ExitNode: peer.ExitNode,
|
||||
ExitNodeOption: peer.ExitNodeOption,
|
||||
ShareeNode: peer.ShareeNode,
|
||||
Expired: peer.Expired,
|
||||
Active: peer.Active,
|
||||
RxBytes: peer.RxBytes,
|
||||
TxBytes: peer.TxBytes,
|
||||
KeyExpiry: peer.KeyExpiry,
|
||||
LastSeen: peer.LastSeen,
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,19 +109,27 @@ func convertTailscalePeer(peer *ipnstate.PeerStatus) *adapter.TailscalePeer {
|
||||
if peer.KeyExpiry != nil {
|
||||
keyExpiry = peer.KeyExpiry.Unix()
|
||||
}
|
||||
var lastSeen int64
|
||||
if !peer.LastSeen.IsZero() {
|
||||
lastSeen = peer.LastSeen.Unix()
|
||||
}
|
||||
return &adapter.TailscalePeer{
|
||||
StableID: string(peer.ID),
|
||||
HostName: peer.HostName,
|
||||
DNSName: peer.DNSName,
|
||||
OS: peer.OS,
|
||||
TailscaleIPs: ips,
|
||||
SSHHostKeys: peer.SSH_HostKeys,
|
||||
Online: peer.Online,
|
||||
ExitNode: peer.ExitNode,
|
||||
ExitNodeOption: peer.ExitNodeOption,
|
||||
ShareeNode: peer.ShareeNode,
|
||||
Expired: peer.Expired,
|
||||
Active: peer.Active,
|
||||
RxBytes: peer.RxBytes,
|
||||
TxBytes: peer.TxBytes,
|
||||
UserID: int64(peer.UserID),
|
||||
KeyExpiry: keyExpiry,
|
||||
LastSeen: lastSeen,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user