get remote ip fix (#254)

* get remote ip fix

* add GetIp fix to chat command
This commit is contained in:
2018-08-28 05:40:30 +03:00
committed by Brant Martin
parent 74b00d3ab1
commit a318aa87cf
2 changed files with 9 additions and 8 deletions

View File

@@ -151,8 +151,11 @@ namespace Torch.Server.Managers
//Largely copied from SE
private void ValidateAuthTicketResponse(ulong steamId, JoinResult response, ulong steamOwner)
{
//SteamNetworking.GetP2PSessionState(new CSteamID(steamId), out P2PSessionState_t state);
var ip = "0"; //state.GetRemoteIP();
//SteamNetworking.GetP2PSessionState(new CSteamID(steamId), out P2PSessionState_t state);
//state.GetRemoteIP();
MyP2PSessionState statehack = new MyP2PSessionState();
VRage.Steam.MySteamService.Static.Peer2Peer.GetSessionState(steamId, ref statehack);
var ip = new IPAddress(BitConverter.GetBytes(statehack.RemoteIP).Reverse().ToArray());
Torch.CurrentSession.KeenSession.PromotedUsers.TryGetValue(steamId, out MyPromoteLevel promoteLevel);

View File

@@ -33,14 +33,12 @@ namespace Torch.Commands
[Permission(MyPromoteLevel.None)]
public void GetIP(ulong steamId = 0)
{
Context.Respond("Cannot obtain client IP.");
return;
if (steamId == 0)
steamId = Context.Player.SteamUserId;
SteamNetworking.GetP2PSessionState(new CSteamID(steamId), out P2PSessionState_t state);
var ip = new IPAddress(BitConverter.GetBytes(state.m_nRemoteIP).Reverse().ToArray());
VRage.GameServices.MyP2PSessionState statehack = new VRage.GameServices.MyP2PSessionState();
VRage.Steam.MySteamService.Static.Peer2Peer.GetSessionState(steamId, ref statehack);
var ip = new IPAddress(BitConverter.GetBytes(statehack.RemoteIP).Reverse().ToArray());
Context.Respond($"Your IP is {ip}");
}