UPNP: now WITHOUT Java!

This commit is contained in:
Bitl 2017-09-02 11:48:14 -07:00
parent c7da857ab8
commit 44b39c3b0e
4 changed files with 520 additions and 26 deletions

450
3DView.rbxl Normal file
View File

@ -0,0 +1,450 @@
<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4">
<External>null</External>
<External>nil</External>
<Item class="Workspace" referent="RBX0">
<Properties>
<Ref name="CurrentCamera">RBX1</Ref>
<double name="DistributedGameTime">0</double>
<CoordinateFrame name="ModelInPrimary">
<X>0</X>
<Y>0</Y>
<Z>0</Z>
<R00>1</R00>
<R01>0</R01>
<R02>0</R02>
<R10>0</R10>
<R11>1</R11>
<R12>0</R12>
<R20>0</R20>
<R21>0</R21>
<R22>1</R22>
</CoordinateFrame>
<string name="Name">Workspace</string>
<Ref name="PrimaryPart">null</Ref>
<bool name="archivable">true</bool>
</Properties>
<Item class="Camera" referent="RBX1">
<Properties>
<Ref name="CameraSubject">null</Ref>
<token name="CameraType">0</token>
<CoordinateFrame name="CoordinateFrame">
<X>2.8825047</X>
<Y>16.8061104</Y>
<Z>19.8420525</Z>
<R00>0.990262866</R00>
<R01>-0.0670645982</R01>
<R02>0.121990994</R02>
<R10>3.7252903e-009</R10>
<R11>0.876308203</R11>
<R12>0.481750816</R12>
<R20>-0.139210135</R20>
<R21>-0.477059931</R21>
<R22>0.8677755</R22>
</CoordinateFrame>
<CoordinateFrame name="Focus">
<X>-0.167192921</X>
<Y>4.76264477</Y>
<Z>-1.85178542</Z>
<R00>1</R00>
<R01>0</R01>
<R02>0</R02>
<R10>0</R10>
<R11>1</R11>
<R12>0</R12>
<R20>0</R20>
<R21>0</R21>
<R22>1</R22>
</CoordinateFrame>
<string name="Name">Camera</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="Model" referent="RBX2">
<Properties>
<CoordinateFrame name="ModelInPrimary">
<X>0</X>
<Y>0</Y>
<Z>0</Z>
<R00>1</R00>
<R01>0</R01>
<R02>0</R02>
<R10>0</R10>
<R11>1</R11>
<R12>0</R12>
<R20>0</R20>
<R21>0</R21>
<R22>1</R22>
</CoordinateFrame>
<string name="Name">Base</string>
<Ref name="PrimaryPart">null</Ref>
<bool name="archivable">true</bool>
</Properties>
<Item class="Part" referent="RBX3">
<Properties>
<bool name="Anchored">true</bool>
<float name="BackParamA">-0.5</float>
<float name="BackParamB">0.5</float>
<token name="BackSurface">0</token>
<token name="BackSurfaceInput">0</token>
<float name="BottomParamA">-0.5</float>
<float name="BottomParamB">0.5</float>
<token name="BottomSurface">0</token>
<token name="BottomSurfaceInput">0</token>
<int name="BrickColor">194</int>
<CoordinateFrame name="CFrame">
<X>0</X>
<Y>1.99999952</Y>
<Z>-0.5</Z>
<R00>1</R00>
<R01>0</R01>
<R02>0</R02>
<R10>0</R10>
<R11>1</R11>
<R12>0</R12>
<R20>0</R20>
<R21>0</R21>
<R22>1</R22>
</CoordinateFrame>
<bool name="CanCollide">true</bool>
<float name="Elasticity">0.5</float>
<token name="FormFactor">2</token>
<float name="Friction">0.300000012</float>
<float name="FrontParamA">-0.5</float>
<float name="FrontParamB">0.5</float>
<token name="FrontSurface">0</token>
<token name="FrontSurfaceInput">0</token>
<float name="LeftParamA">-0.5</float>
<float name="LeftParamB">0.5</float>
<token name="LeftSurface">0</token>
<token name="LeftSurfaceInput">0</token>
<bool name="Locked">false</bool>
<token name="Material">256</token>
<string name="Name">Part</string>
<float name="Reflectance">0</float>
<float name="RightParamA">-0.5</float>
<float name="RightParamB">0.5</float>
<token name="RightSurface">0</token>
<token name="RightSurfaceInput">0</token>
<Vector3 name="RotVelocity">
<X>0</X>
<Y>0</Y>
<Z>0</Z>
</Vector3>
<float name="TopParamA">-0.5</float>
<float name="TopParamB">0.5</float>
<token name="TopSurface">0</token>
<token name="TopSurfaceInput">0</token>
<float name="Transparency">0</float>
<Vector3 name="Velocity">
<X>0</X>
<Y>0</Y>
<Z>0</Z>
</Vector3>
<bool name="archivable">true</bool>
<token name="shape">1</token>
<Vector3 name="size">
<X>18</X>
<Y>0.400000006</Y>
<Z>18</Z>
</Vector3>
</Properties>
</Item>
<Item class="SpawnLocation" referent="RBX4">
<Properties>
<bool name="AllowTeamChangeOnTouch">false</bool>
<bool name="Anchored">true</bool>
<float name="BackParamA">-0.5</float>
<float name="BackParamB">0.5</float>
<token name="BackSurface">0</token>
<token name="BackSurfaceInput">0</token>
<float name="BottomParamA">-0.5</float>
<float name="BottomParamB">0.5</float>
<token name="BottomSurface">4</token>
<token name="BottomSurfaceInput">0</token>
<int name="BrickColor">194</int>
<CoordinateFrame name="CFrame">
<X>0</X>
<Y>2.39999986</Y>
<Z>-0.5</Z>
<R00>1</R00>
<R01>0</R01>
<R02>0</R02>
<R10>0</R10>
<R11>1</R11>
<R12>0</R12>
<R20>0</R20>
<R21>0</R21>
<R22>1</R22>
</CoordinateFrame>
<bool name="CanCollide">false</bool>
<int name="Duration">0</int>
<float name="Elasticity">0.5</float>
<token name="FormFactor">2</token>
<float name="Friction">0.300000012</float>
<float name="FrontParamA">-0.5</float>
<float name="FrontParamB">0.5</float>
<token name="FrontSurface">0</token>
<token name="FrontSurfaceInput">0</token>
<float name="LeftParamA">-0.5</float>
<float name="LeftParamB">0.5</float>
<token name="LeftSurface">0</token>
<token name="LeftSurfaceInput">0</token>
<bool name="Locked">true</bool>
<token name="Material">256</token>
<string name="Name">SpawnLocation</string>
<bool name="Neutral">true</bool>
<float name="Reflectance">0</float>
<float name="RightParamA">-0.5</float>
<float name="RightParamB">0.5</float>
<token name="RightSurface">0</token>
<token name="RightSurfaceInput">0</token>
<Vector3 name="RotVelocity">
<X>0</X>
<Y>0</Y>
<Z>0</Z>
</Vector3>
<int name="TeamColor">194</int>
<float name="TopParamA">-0.5</float>
<float name="TopParamB">0.5</float>
<token name="TopSurface">3</token>
<token name="TopSurfaceInput">0</token>
<float name="Transparency">1</float>
<Vector3 name="Velocity">
<X>0</X>
<Y>0</Y>
<Z>0</Z>
</Vector3>
<bool name="archivable">true</bool>
<token name="shape">1</token>
<Vector3 name="size">
<X>2</X>
<Y>0.400000006</Y>
<Z>1</Z>
</Vector3>
</Properties>
</Item>
</Item>
</Item>
<Item class="RunService" referent="RBX5">
<Properties>
<string name="Name">Run Service</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="ContentProvider" referent="RBX6">
<Properties>
<string name="Name">Instance</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="ContentFilter" referent="RBX7">
<Properties>
<string name="Name">ContentFilter</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="KeyframeSequenceProvider" referent="RBX8">
<Properties>
<string name="Name">Instance</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="Players" referent="RBX9">
<Properties>
<int name="MaxPlayers">12</int>
<string name="Name">Players</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="StarterPack" referent="RBX10">
<Properties>
<string name="Name">StarterPack</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="StarterGui" referent="RBX11">
<Properties>
<string name="Name">StarterGui</string>
<bool name="ShowDevelopmentGui">true</bool>
<bool name="archivable">true</bool>
</Properties>
<Item class="ScreenGui" referent="RBX12">
<Properties>
<string name="Name">3DViewUI</string>
<bool name="archivable">true</bool>
</Properties>
<Item class="TextButton" referent="RBX13">
<Properties>
<bool name="Active">true</bool>
<bool name="AutoButtonColor">true</bool>
<Color3 name="BackgroundColor3">4288914085</Color3>
<float name="BackgroundTransparency">0.400000006</float>
<Color3 name="BorderColor3">4279970357</Color3>
<int name="BorderSizePixel">0</int>
<token name="Font">0</token>
<token name="FontSize">0</token>
<string name="Name">Transparency</string>
<UDim2 name="Position">
<XS>1</XS>
<XO>-155</XO>
<YS>1</YS>
<YO>-50</YO>
</UDim2>
<bool name="Selected">false</bool>
<UDim2 name="Size">
<XS>0</XS>
<XO>150</XO>
<YS>0</YS>
<YO>20</YO>
</UDim2>
<token name="SizeConstraint">0</token>
<token name="Style">0</token>
<string name="Text">Change Base Transparency</string>
<Color3 name="TextColor3">4283256141</Color3>
<float name="TextTransparency">0</float>
<bool name="TextWrap">false</bool>
<token name="TextXAlignment">2</token>
<token name="TextYAlignment">1</token>
<bool name="Visible">true</bool>
<int name="ZIndex">1</int>
<bool name="archivable">true</bool>
</Properties>
<Item class="LocalScript" referent="RBX14">
<Properties>
<bool name="Disabled">false</bool>
<Content name="LinkedSource"><null></null></Content>
<string name="Name">LocalScript</string>
<ProtectedString name="Source">function onClicked()
if (game.Workspace.Base.Part.Transparency == 0) then
game.Workspace.Base.Part.Transparency = 0.5
elseif (game.Workspace.Base.Part.Transparency == 0.5) then
game.Workspace.Base.Part.Transparency = 1
elseif (game.Workspace.Base.Part.Transparency == 1) then
game.Workspace.Base.Part.Transparency = 0
end
end
script.Parent.MouseButton1Down:connect(onClicked)</ProtectedString>
<bool name="archivable">true</bool>
</Properties>
</Item>
</Item>
</Item>
</Item>
<Item class="SoundService" referent="RBX15">
<Properties>
<token name="AmbientReverb">0</token>
<float name="DistanceFactor">10</float>
<float name="DopplerScale">1</float>
<string name="Name">Soundscape</string>
<float name="RolloffScale">1</float>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="CollectionService" referent="RBX16">
<Properties>
<string name="Name">CollectionService</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="PhysicsService" referent="RBX17">
<Properties>
<string name="Name">PhysicsService</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="BadgeService" referent="RBX18">
<Properties>
<string name="Name">BadgeService</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="Geometry" referent="RBX19">
<Properties>
<string name="Name">Geometry</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="RenderHooksService" referent="RBX20">
<Properties>
<string name="Name">RenderHooksService</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="SocialService" referent="RBX21">
<Properties>
<string name="Name">SocialService</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="Debris" referent="RBX22">
<Properties>
<int name="MaxItems">1000</int>
<string name="Name">Debris</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="Timer" referent="RBX23">
<Properties>
<string name="Name">Instance</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="ScriptInformationProvider" referent="RBX24">
<Properties>
<string name="Name">Instance</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="Selection" referent="RBX25">
<Properties>
<string name="Name">Selection</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="Lighting" referent="RBX26">
<Properties>
<Color3 name="Ambient">4286874756</Color3>
<float name="Brightness">1</float>
<Color3 name="ColorShift_Bottom">4278190080</Color3>
<Color3 name="ColorShift_Top">4278190080</Color3>
<float name="GeographicLatitude">41.7332993</float>
<string name="Name">Lighting</string>
<Color3 name="ShadowColor">4290230204</Color3>
<string name="TimeOfDay">14:00:00</string>
<bool name="archivable">true</bool>
</Properties>
<Item class="Sky" referent="RBX27">
<Properties>
<bool name="CelestialBodiesShown">false</bool>
<string name="Name">Sky</string>
<Content name="SkyboxBk"><url>rbxasset://Sky/null_plainsky512_bk.jpg</url></Content>
<Content name="SkyboxDn"><url>rbxasset://Sky/null_plainsky512_dn.jpg</url></Content>
<Content name="SkyboxFt"><url>rbxasset://Sky/null_plainsky512_ft.jpg</url></Content>
<Content name="SkyboxLf"><url>rbxasset://Sky/null_plainsky512_lf.jpg</url></Content>
<Content name="SkyboxRt"><url>rbxasset://Sky/null_plainsky512_rt.jpg</url></Content>
<Content name="SkyboxUp"><url>rbxasset://Sky/null_plainsky512_up.jpg</url></Content>
<int name="StarCount">3000</int>
<bool name="archivable">true</bool>
</Properties>
</Item>
</Item>
<Item class="ChangeHistoryService" referent="RBX28">
<Properties>
<string name="Name">ChangeHistoryService</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="MeshContentProvider" referent="RBX29">
<Properties>
<string name="Name">Instance</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
<Item class="TextureContentProvider" referent="RBX30">
<Properties>
<string name="Name">Instance</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
</roblox>

View File

@ -110,12 +110,10 @@ namespace RBXLegacyLauncher
{
if (GlobalVars.upnp == true)
{
Process pmap = new Process();
pmap.StartInfo.FileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\jreportable\\bin\\java.exe";
pmap.StartInfo.Arguments = "-jar upnp.jar -externalPort" + GlobalVars.ServerPort + " -internalPort" + GlobalVars.ServerPort + "-ip \"localhost\" -protocol udp";
pmap.StartInfo.UseShellExecute = false;
pmap.StartInfo.CreateNoWindow = true;
pmap.Start();
NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
mappings.Add(GlobalVars.ServerPort, "TCP", GlobalVars.ServerPort, SecurityFuncs.GetLocalIPAddress(), true, "RBXLegacy Server Port TCP");
mappings.Add(GlobalVars.ServerPort, "UDP", GlobalVars.ServerPort, SecurityFuncs.GetLocalIPAddress(), true, "RBXLegacy Server Port UDP");
}
WriteConfigValues();
StartServer();
@ -772,7 +770,14 @@ namespace RBXLegacyLauncher
try
{
ConsolePrint("Server Loaded.", 4);
Process.Start(rbxexe, args);
Process server = new Process();
server.StartInfo.FileName = rbxexe;
server.StartInfo.Arguments = args;
if (GlobalVars.upnp == true)
{
server.Exited += new EventHandler(ServerExited);
}
server.Start();
}
catch (Exception ex)
{
@ -799,7 +804,14 @@ namespace RBXLegacyLauncher
try
{
ConsolePrint("Server Loaded in No3D mode.", 4);
Process.Start(rbxexe, args);
Process server = new Process();
server.StartInfo.FileName = rbxexe;
server.StartInfo.Arguments = args;
if (GlobalVars.upnp == true)
{
server.Exited += new EventHandler(ServerExited);
}
server.Start();
}
catch (Exception ex)
{
@ -808,6 +820,15 @@ namespace RBXLegacyLauncher
}
}
void ServerExited(object sender, EventArgs e)
{
NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
mappings.Remove(GlobalVars.ServerPort, "TCP");
mappings.Remove(GlobalVars.ServerPort, "UDP");
}
void StartStudio()
{
string mapfile = GlobalVars.MapsDir + @"\\" + GlobalVars.Map;
@ -850,12 +871,10 @@ namespace RBXLegacyLauncher
{
if (GlobalVars.upnp == true)
{
Process pmap = new Process();
pmap.StartInfo.FileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\jreportable\\bin\\java.exe";
pmap.StartInfo.Arguments = "-jar upnp.jar -externalPort" + GlobalVars.ServerPort + " -internalPort" + GlobalVars.ServerPort + "-ip \"localhost\" -protocol udp";
pmap.StartInfo.UseShellExecute = false;
pmap.StartInfo.CreateNoWindow = true;
pmap.Start();
NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
mappings.Add(GlobalVars.ServerPort, "TCP", GlobalVars.ServerPort, SecurityFuncs.GetLocalIPAddress(), true, "RBXLegacy Server Port TCP");
mappings.Add(GlobalVars.ServerPort, "UDP", GlobalVars.ServerPort, SecurityFuncs.GetLocalIPAddress(), true, "RBXLegacy Server Port UDP");
}
StartServer();
}
@ -863,23 +882,22 @@ namespace RBXLegacyLauncher
{
if (GlobalVars.upnp == true)
{
Process pmap = new Process();
pmap.StartInfo.FileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\jreportable\\bin\\java.exe";
pmap.StartInfo.Arguments = "-jar upnp.jar -externalPort" + GlobalVars.ServerPort + " -internalPort" + GlobalVars.ServerPort + "-ip \"localhost\" -protocol udp";
pmap.StartInfo.UseShellExecute = false;
pmap.StartInfo.CreateNoWindow = true;
pmap.Start();
NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
mappings.Add(GlobalVars.ServerPort, "TCP", GlobalVars.ServerPort, SecurityFuncs.GetLocalIPAddress(), true, "RBXLegacy Server Port TCP");
mappings.Add(GlobalVars.ServerPort, "UDP", GlobalVars.ServerPort, SecurityFuncs.GetLocalIPAddress(), true, "RBXLegacy Server Port UDP");
}
StartServerNo3D();
}
else if (command.Equals("rbxlegacy no3d"))
{
Process pmap = new Process();
pmap.StartInfo.FileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\jreportable\\bin\\java.exe";
pmap.StartInfo.Arguments = "-jar upnp.jar -externalPort" + GlobalVars.ServerPort + " -internalPort" + GlobalVars.ServerPort + "-ip \"localhost\" -protocol udp";
pmap.StartInfo.UseShellExecute = false;
pmap.StartInfo.CreateNoWindow = true;
pmap.Start();
if (GlobalVars.upnp == true)
{
NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
mappings.Add(GlobalVars.ServerPort, "TCP", GlobalVars.ServerPort, SecurityFuncs.GetLocalIPAddress(), true, "RBXLegacy Server Port TCP");
mappings.Add(GlobalVars.ServerPort, "UDP", GlobalVars.ServerPort, SecurityFuncs.GetLocalIPAddress(), true, "RBXLegacy Server Port UDP");
}
StartServerNo3D();
}
else if (command.Equals("rbxlegacy client"))

View File

@ -119,5 +119,15 @@
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<COMReference Include="NATUPNPLib">
<Guid>{1C565858-F302-471E-B409-F180AA4ABEC6}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -6,6 +6,8 @@ using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Net;
using System.Net.Sockets;
using Microsoft.Win32;
namespace RBXLegacyLauncher
@ -83,5 +85,19 @@ namespace RBXLegacyLauncher
}
}
}
public static string GetLocalIPAddress()
{
string str = "";
foreach (IPAddress address in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
{
if (address.AddressFamily == AddressFamily.InterNetwork)
{
str = address.ToString();
break;
}
}
return str;
}
}
}