mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-02-06 02:30:36 +03:00
SteamIPAddress takeover
This commit is contained in:
parent
26e634a7f0
commit
ea60c03b95
@ -96,10 +96,10 @@ namespace Steamworks
|
|||||||
|
|
||||||
#region FunctionMeta
|
#region FunctionMeta
|
||||||
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamClient_SetLocalIPBinding")]
|
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamClient_SetLocalIPBinding")]
|
||||||
private static extern void _SetLocalIPBinding( IntPtr self, ref SteamIPAddress_t unIP, ushort usPort );
|
private static extern void _SetLocalIPBinding( IntPtr self, ref SteamIPAddress unIP, ushort usPort );
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
internal void SetLocalIPBinding( ref SteamIPAddress_t unIP, ushort usPort )
|
internal void SetLocalIPBinding( ref SteamIPAddress unIP, ushort usPort )
|
||||||
{
|
{
|
||||||
_SetLocalIPBinding( Self, ref unIP, usPort );
|
_SetLocalIPBinding( Self, ref unIP, usPort );
|
||||||
}
|
}
|
||||||
|
@ -387,10 +387,10 @@ namespace Steamworks
|
|||||||
|
|
||||||
#region FunctionMeta
|
#region FunctionMeta
|
||||||
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamGameServer_GetPublicIP")]
|
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamGameServer_GetPublicIP")]
|
||||||
private static extern SteamIPAddress_t _GetPublicIP( IntPtr self );
|
private static extern SteamIPAddress _GetPublicIP( IntPtr self );
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
internal SteamIPAddress_t GetPublicIP()
|
internal SteamIPAddress GetPublicIP()
|
||||||
{
|
{
|
||||||
var returnValue = _GetPublicIP( Self );
|
var returnValue = _GetPublicIP( Self );
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
@ -115,10 +115,10 @@ namespace Steamworks
|
|||||||
|
|
||||||
#region FunctionMeta
|
#region FunctionMeta
|
||||||
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworking_CreateListenSocket")]
|
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworking_CreateListenSocket")]
|
||||||
private static extern SNetListenSocket_t _CreateListenSocket( IntPtr self, int nVirtualP2PPort, SteamIPAddress_t nIP, ushort nPort, [MarshalAs( UnmanagedType.U1 )] bool bAllowUseOfPacketRelay );
|
private static extern SNetListenSocket_t _CreateListenSocket( IntPtr self, int nVirtualP2PPort, SteamIPAddress nIP, ushort nPort, [MarshalAs( UnmanagedType.U1 )] bool bAllowUseOfPacketRelay );
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
internal SNetListenSocket_t CreateListenSocket( int nVirtualP2PPort, SteamIPAddress_t nIP, ushort nPort, [MarshalAs( UnmanagedType.U1 )] bool bAllowUseOfPacketRelay )
|
internal SNetListenSocket_t CreateListenSocket( int nVirtualP2PPort, SteamIPAddress nIP, ushort nPort, [MarshalAs( UnmanagedType.U1 )] bool bAllowUseOfPacketRelay )
|
||||||
{
|
{
|
||||||
var returnValue = _CreateListenSocket( Self, nVirtualP2PPort, nIP, nPort, bAllowUseOfPacketRelay );
|
var returnValue = _CreateListenSocket( Self, nVirtualP2PPort, nIP, nPort, bAllowUseOfPacketRelay );
|
||||||
return returnValue;
|
return returnValue;
|
||||||
@ -137,10 +137,10 @@ namespace Steamworks
|
|||||||
|
|
||||||
#region FunctionMeta
|
#region FunctionMeta
|
||||||
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworking_CreateConnectionSocket")]
|
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworking_CreateConnectionSocket")]
|
||||||
private static extern SNetSocket_t _CreateConnectionSocket( IntPtr self, SteamIPAddress_t nIP, ushort nPort, int nTimeoutSec );
|
private static extern SNetSocket_t _CreateConnectionSocket( IntPtr self, SteamIPAddress nIP, ushort nPort, int nTimeoutSec );
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
internal SNetSocket_t CreateConnectionSocket( SteamIPAddress_t nIP, ushort nPort, int nTimeoutSec )
|
internal SNetSocket_t CreateConnectionSocket( SteamIPAddress nIP, ushort nPort, int nTimeoutSec )
|
||||||
{
|
{
|
||||||
var returnValue = _CreateConnectionSocket( Self, nIP, nPort, nTimeoutSec );
|
var returnValue = _CreateConnectionSocket( Self, nIP, nPort, nTimeoutSec );
|
||||||
return returnValue;
|
return returnValue;
|
||||||
@ -233,10 +233,10 @@ namespace Steamworks
|
|||||||
#region FunctionMeta
|
#region FunctionMeta
|
||||||
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworking_GetSocketInfo")]
|
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworking_GetSocketInfo")]
|
||||||
[return: MarshalAs( UnmanagedType.I1 )]
|
[return: MarshalAs( UnmanagedType.I1 )]
|
||||||
private static extern bool _GetSocketInfo( IntPtr self, SNetSocket_t hSocket, ref SteamId pSteamIDRemote, ref int peSocketStatus, ref SteamIPAddress_t punIPRemote, ref ushort punPortRemote );
|
private static extern bool _GetSocketInfo( IntPtr self, SNetSocket_t hSocket, ref SteamId pSteamIDRemote, ref int peSocketStatus, ref SteamIPAddress punIPRemote, ref ushort punPortRemote );
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
internal bool GetSocketInfo( SNetSocket_t hSocket, ref SteamId pSteamIDRemote, ref int peSocketStatus, ref SteamIPAddress_t punIPRemote, ref ushort punPortRemote )
|
internal bool GetSocketInfo( SNetSocket_t hSocket, ref SteamId pSteamIDRemote, ref int peSocketStatus, ref SteamIPAddress punIPRemote, ref ushort punPortRemote )
|
||||||
{
|
{
|
||||||
var returnValue = _GetSocketInfo( Self, hSocket, ref pSteamIDRemote, ref peSocketStatus, ref punIPRemote, ref punPortRemote );
|
var returnValue = _GetSocketInfo( Self, hSocket, ref pSteamIDRemote, ref peSocketStatus, ref punIPRemote, ref punPortRemote );
|
||||||
return returnValue;
|
return returnValue;
|
||||||
@ -245,10 +245,10 @@ namespace Steamworks
|
|||||||
#region FunctionMeta
|
#region FunctionMeta
|
||||||
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworking_GetListenSocketInfo")]
|
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworking_GetListenSocketInfo")]
|
||||||
[return: MarshalAs( UnmanagedType.I1 )]
|
[return: MarshalAs( UnmanagedType.I1 )]
|
||||||
private static extern bool _GetListenSocketInfo( IntPtr self, SNetListenSocket_t hListenSocket, ref SteamIPAddress_t pnIP, ref ushort pnPort );
|
private static extern bool _GetListenSocketInfo( IntPtr self, SNetListenSocket_t hListenSocket, ref SteamIPAddress pnIP, ref ushort pnPort );
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
internal bool GetListenSocketInfo( SNetListenSocket_t hListenSocket, ref SteamIPAddress_t pnIP, ref ushort pnPort )
|
internal bool GetListenSocketInfo( SNetListenSocket_t hListenSocket, ref SteamIPAddress pnIP, ref ushort pnPort )
|
||||||
{
|
{
|
||||||
var returnValue = _GetListenSocketInfo( Self, hListenSocket, ref pnIP, ref pnPort );
|
var returnValue = _GetListenSocketInfo( Self, hListenSocket, ref pnIP, ref pnPort );
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
@ -6,15 +6,6 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Steamworks.Data
|
namespace Steamworks.Data
|
||||||
{
|
{
|
||||||
[StructLayout( LayoutKind.Sequential, Pack = Platform.StructPlatformPackSize )]
|
|
||||||
internal struct SteamIPAddress_t
|
|
||||||
{
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] // m_rgubIPv6
|
|
||||||
internal byte[] GubIPv6; // m_rgubIPv6 uint8 [16]
|
|
||||||
internal SteamIPType Type; // m_eType ESteamIPType
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout( LayoutKind.Sequential, Pack = Platform.StructPackSize )]
|
[StructLayout( LayoutKind.Sequential, Pack = Platform.StructPackSize )]
|
||||||
internal struct FriendGameInfo_t
|
internal struct FriendGameInfo_t
|
||||||
{
|
{
|
||||||
|
@ -298,16 +298,7 @@ namespace Steamworks
|
|||||||
/// current public ip address. Be aware that this is likely to return
|
/// current public ip address. Be aware that this is likely to return
|
||||||
/// null for the first few seconds after initialization.
|
/// null for the first few seconds after initialization.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static System.Net.IPAddress PublicIp
|
public static System.Net.IPAddress PublicIp => Internal.GetPublicIP();
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var ip = Internal.GetPublicIP();
|
|
||||||
if ( ip == 0 ) return null;
|
|
||||||
|
|
||||||
return Utility.Int32ToIp( ip );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enable or disable heartbeats, which are sent regularly to the master server.
|
/// Enable or disable heartbeats, which are sent regularly to the master server.
|
||||||
|
26
Facepunch.Steamworks/Structs/SteamIpAddress.cs
Normal file
26
Facepunch.Steamworks/Structs/SteamIpAddress.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Steamworks.Data
|
||||||
|
{
|
||||||
|
[StructLayout( LayoutKind.Explicit, Pack = Platform.StructPlatformPackSize )]
|
||||||
|
internal struct SteamIPAddress
|
||||||
|
{
|
||||||
|
[FieldOffset( 0 )]
|
||||||
|
public uint Ip4Address; // Host Order
|
||||||
|
|
||||||
|
[FieldOffset( 16 )]
|
||||||
|
internal SteamIPType Type; // m_eType ESteamIPType
|
||||||
|
|
||||||
|
public static implicit operator System.Net.IPAddress( SteamIPAddress value )
|
||||||
|
{
|
||||||
|
if ( value.Type == SteamIPType.Type4 )
|
||||||
|
return Utility.Int32ToIp( value.Ip4Address );
|
||||||
|
|
||||||
|
throw new System.Exception( $"Oops - can't convert SteamIPAddress to System.Net.IPAddress because no-one coded support for {value.Type} yet" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -54,6 +54,7 @@ public static class Cleanup
|
|||||||
type = type.Replace( "MatchMakingKeyValuePair_t", "MatchMakingKeyValuePair" );
|
type = type.Replace( "MatchMakingKeyValuePair_t", "MatchMakingKeyValuePair" );
|
||||||
type = type.Replace( "ISteamNetworkingMessage", "NetMsg" );
|
type = type.Replace( "ISteamNetworkingMessage", "NetMsg" );
|
||||||
type = type.Replace( "SteamNetworkingMessage_t", "NetMsg" );
|
type = type.Replace( "SteamNetworkingMessage_t", "NetMsg" );
|
||||||
|
type = type.Replace( "SteamIPAddress_t", "SteamIPAddress" );
|
||||||
|
|
||||||
type = type.Replace( "::", "." );
|
type = type.Replace( "::", "." );
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ public static class Cleanup
|
|||||||
if ( type == "SteamNetworkingQuickConnectionStatus" ) return false;
|
if ( type == "SteamNetworkingQuickConnectionStatus" ) return false;
|
||||||
if ( type == "SteamNetworkingErrMsg" ) return false;
|
if ( type == "SteamNetworkingErrMsg" ) return false;
|
||||||
if ( type == "NetKeyValue" ) return false;
|
if ( type == "NetKeyValue" ) return false;
|
||||||
|
if ( type == "SteamIPAddress" ) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ internal class BaseType
|
|||||||
if ( basicType == "MotionState" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
if ( basicType == "MotionState" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||||
if ( basicType == "NetMsg" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
if ( basicType == "NetMsg" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||||
if ( basicType == "NetKeyValue" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
if ( basicType == "NetKeyValue" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||||
|
if ( basicType == "SteamIPAddress" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||||
if ( basicType.StartsWith( "E" ) && char.IsUpper( basicType[1] ) ) return new EnumType { NativeType = type.Substring( 1 ), VarName = varname };
|
if ( basicType.StartsWith( "E" ) && char.IsUpper( basicType[1] ) ) return new EnumType { NativeType = type.Substring( 1 ), VarName = varname };
|
||||||
if ( basicType.EndsWith( "_t" ) ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
if ( basicType.EndsWith( "_t" ) ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user