forked from GameProgressive/UniSpyServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88874dd
commit fee865e
Showing
49 changed files
with
562 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name: CD - GSTATS | ||
name: CD - GS | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'src/Servers/StatsAndTracking/**' | ||
- 'src/Servers/GameStatus/**' | ||
branches: | ||
- master | ||
- candidate | ||
|
@@ -34,21 +34,21 @@ jobs: | |
DOCKER_HUB_KEY: ${{ secrets.DOCKER_HUB_KEY }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Deploy GSTATS to staging | ||
- name: Deploy GS to staging | ||
if: github.ref == 'refs/heads/candidate' | ||
uses: elgohr/[email protected] | ||
with: | ||
name: gameprogressive/gstats | ||
username: ${{ secrets.DOCKER_HUB_USER }} | ||
password: ${{ secrets.DOCKER_HUB_KEY }} | ||
tagging: true | ||
dockerfile: ./src/Servers/StatsAndTracking/Dockerfile | ||
- name: Deploy GSTATS to production | ||
dockerfile: ./src/Servers/GameStatus/Dockerfile | ||
- name: Deploy GS to production | ||
if: github.ref == 'refs/heads/master' | ||
uses: elgohr/[email protected] | ||
with: | ||
name: gameprogressive/gstats | ||
username: ${{ secrets.DOCKER_HUB_USER }} | ||
password: ${{ secrets.DOCKER_HUB_KEY }} | ||
tagging: true | ||
dockerfile: ./src/Servers/StatsAndTracking/Dockerfile | ||
dockerfile: ./src/Servers/GameStatus/Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name: CD - NatNeg | ||
name: CD - NN | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'src/Servers/NatNegotiation/**' | ||
- 'src/Servers/NATNegotiation/**' | ||
branches: | ||
- master | ||
- candidate | ||
|
@@ -34,21 +34,21 @@ jobs: | |
DOCKER_HUB_KEY: ${{ secrets.DOCKER_HUB_KEY }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Deploy NatNeg to staging | ||
- name: Deploy NN to staging | ||
if: github.ref == 'refs/heads/candidate' | ||
uses: elgohr/[email protected] | ||
with: | ||
name: gameprogressive/natneg | ||
name: gameprogressive/nn | ||
username: ${{ secrets.DOCKER_HUB_USER }} | ||
password: ${{ secrets.DOCKER_HUB_KEY }} | ||
tagging: true | ||
dockerfile: ./src/Servers/NatNegotiation/Dockerfile | ||
- name: Deploy NatNeg to production | ||
dockerfile: ./src/Servers/NATNegotiation/Dockerfile | ||
- name: Deploy NN to production | ||
if: github.ref == 'refs/heads/master' | ||
uses: elgohr/[email protected] | ||
with: | ||
name: gameprogressive/natneg | ||
name: gameprogressive/nn | ||
username: ${{ secrets.DOCKER_HUB_USER }} | ||
password: ${{ secrets.DOCKER_HUB_KEY }} | ||
tagging: true | ||
dockerfile: ./src/Servers/NatNegotiation/Dockerfile | ||
dockerfile: ./src/Servers/NATNegotiation/Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.7-alpine3.12 AS base | ||
WORKDIR /app | ||
EXPOSE 29920 | ||
|
||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1.401-alpine3.12 AS build | ||
WORKDIR /src | ||
COPY ["src/Servers/GameStatus/GameStatus.csproj", "src/Servers/GameStatus/"] | ||
COPY ["src/Libraries/GameSpyLib/GameSpyLib.csproj", "src/Libraries/GameSpyLib/"] | ||
RUN dotnet restore "src/Servers/GameStatus/GameStatus.csproj" | ||
COPY . . | ||
WORKDIR "/src/src/Servers/GameStatus" | ||
RUN dotnet build "GameStatus.csproj" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "GameStatus.csproj" -c Release -o /app/publish | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
COPY ./common/RetroSpyServer.json . | ||
ENTRYPOINT ["dotnet", "GameStatus.dll"] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using GameSpyLib.Abstraction.BaseClass; | ||
using GameSpyLib.Entity.Structure; | ||
using GameSpyLib.Logging; | ||
using Serilog.Events; | ||
using System; | ||
namespace NATNegotiation.Application | ||
{ | ||
/// <summary> | ||
/// This class represents a RetroSpy Server program | ||
/// </summary> | ||
internal class Program | ||
{ | ||
private static ServerManager Manager; | ||
|
||
private static void Main(string[] args) | ||
{ | ||
|
||
try | ||
{ | ||
//create a instance of ServerManager class | ||
Manager = new ServerManager(RetroSpyServerName.NATNegotiation); | ||
Manager.Start(); | ||
Console.Title = "RetroSpy Server " + ServerManagerBase.RetroSpyVersion; | ||
} | ||
catch (Exception e) | ||
{ | ||
LogWriter.ToLog(LogEventLevel.Error, e.ToString()); | ||
} | ||
|
||
|
||
Console.WriteLine("Press < Q > to exit. "); | ||
while (Console.ReadKey().Key != ConsoleKey.Q) { } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using GameSpyLib.Abstraction.BaseClass; | ||
using GameSpyLib.Extensions; | ||
using GameSpyLib.RetroSpyConfig; | ||
using NATNegotiation.Server; | ||
using System; | ||
using System.Net; | ||
|
||
namespace NATNegotiation.Application | ||
{ | ||
/// <summary> | ||
/// A factory that create the instance of servers | ||
/// </summary> | ||
public class ServerManager : ServerManagerBase | ||
{ | ||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
/// <param name="serverName">Server name in config file</param> | ||
public ServerManager(string serverName) : base(serverName) | ||
{ | ||
} | ||
|
||
public override void Start() | ||
{ | ||
ShowRetroSpyLogo(); | ||
//LoadDatabaseConfig(); | ||
LoadServerConfig(); | ||
} | ||
/// <summary> | ||
/// Starts a specific server | ||
/// </summary> | ||
/// <param name="cfg">The configuration of the specific server to run</param> | ||
protected override void StartServer(ServerConfig cfg) | ||
{ | ||
if (cfg.Name == ServerName) | ||
{ | ||
Server = new NatNegServer(IPAddress.Parse(cfg.ListeningAddress), cfg.ListeningPort).Start(); | ||
Console.WriteLine( | ||
StringExtensions.FormatServerTableContext(cfg.Name, cfg.ListeningAddress, cfg.ListeningPort.ToString())); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.7-alpine3.12 AS base | ||
WORKDIR /app | ||
EXPOSE 27901 | ||
EXPOSE 27901/udp | ||
|
||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1.401-alpine3.12 AS build | ||
WORKDIR /src | ||
COPY ["src/Servers/NATNegotiation/NATNegotiation.csproj", "src/Servers/NATNegotiation/"] | ||
COPY ["src/Libraries/GameSpyLib/GameSpyLib.csproj", "src/Libraries/GameSpyLib/"] | ||
RUN dotnet restore "src/Servers/NATNegotiation/NATNegotiation.csproj" | ||
COPY . . | ||
WORKDIR "/src/src/Servers/NATNegotiation" | ||
RUN dotnet build "NATNegotiation.csproj" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "NATNegotiation.csproj" -c Release -o /app/publish | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
COPY ./common/RetroSpyServer.json . | ||
ENTRYPOINT ["dotnet", "NATNegotiation.dll"] |
15 changes: 15 additions & 0 deletions
15
src/Servers/NATNegotiation/Entity/Enumerator/NNErrorCode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace NATNegotiation.Entity.Enumerate | ||
{ | ||
public enum NNErrorCode | ||
{ | ||
NoError, | ||
RequestError, | ||
MagicDataError, | ||
VersionError, | ||
PacketTypeError, | ||
CookieError, | ||
InitPacketError, | ||
ConnectPacketError, | ||
ReportPacketError | ||
} | ||
} |
113 changes: 113 additions & 0 deletions
113
src/Servers/NATNegotiation/Entity/Enumerator/NatNegEnum.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
namespace NATNegotiation.Entity.Enumerate | ||
{ | ||
public enum ConnectPacketFinishStatus : byte | ||
{ | ||
NoError, | ||
DeadHeartBeat, | ||
InitPacketTimeOut | ||
} | ||
|
||
public enum NatPortType : byte | ||
{ | ||
/// <summary> | ||
/// Use game port for nat neg | ||
/// </summary> | ||
GP, | ||
/// <summary> | ||
/// IP and Port both restricted | ||
/// </summary> | ||
NN1, | ||
/// <summary> | ||
/// IP not restricted | ||
/// </summary> | ||
NN2, | ||
/// <summary> | ||
/// Port not restriced | ||
/// </summary> | ||
NN3 | ||
} | ||
|
||
public enum NatPacketType : byte | ||
{ | ||
/// <summary> | ||
/// Initialize nat negotiation with cookie | ||
/// </summary> | ||
Init, | ||
InitAck, | ||
/// <summary> | ||
/// External reachability test | ||
/// </summary> | ||
ErtTest, | ||
ErtAck, | ||
StateUpdate, | ||
/// <summary> | ||
/// Notify participant to negotiate | ||
/// </summary> | ||
Connect, | ||
ConnectAck, | ||
/// <summary> | ||
/// Connect other participant with ping packet | ||
/// </summary> | ||
ConnectPing, | ||
BackupTest, | ||
BackupAck, | ||
AddressCheck, | ||
AddressReply, | ||
NatifyRequest, | ||
Report, | ||
ReportAck, | ||
PreInit, | ||
PreInitAck, | ||
} | ||
|
||
internal enum NatifyPacketType : byte | ||
{ | ||
PacketMap1a, | ||
PacketMap2, | ||
PacketMap3, | ||
PacketMap1b, | ||
NumPackets | ||
} | ||
|
||
public enum NATNegotiationMappingScheme : byte | ||
{ | ||
Unrecognized, | ||
PrivateAsPublic, | ||
ConsistentPort, | ||
Incremental, | ||
Mixed, | ||
NumMappingSchemes | ||
} | ||
|
||
public enum NATNegotiationType | ||
{ | ||
NoNat, | ||
FirewallOnly, | ||
FullCone, | ||
RestrictedCone, | ||
PortRestrictedCone, | ||
Symmetric, | ||
Unknown, | ||
NumNatTypes | ||
} | ||
|
||
public enum NatPromiscuity | ||
{ | ||
Promiscuous, | ||
NotPromiscuous, | ||
PortPromiscuous, | ||
IPPromiscuous, | ||
PromiscuityNotApplicable, | ||
NumPromiscuityTypes | ||
} | ||
|
||
public enum NATNegotiationResult | ||
{ | ||
Success, | ||
DeadBeatPartner, | ||
InitTimeOut, | ||
PingTimeOut, | ||
UnknownError, | ||
NoResult | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace NATNegotiation.Entity.Structure | ||
{ | ||
public class GameInfo | ||
{ | ||
public int ID; | ||
public string Name; | ||
public string Secretkey; | ||
public ushort QueryPort; | ||
public ushort BackendFlags; | ||
public uint ServicesDisabled; | ||
public KeyData PushKeys; | ||
public byte NumPushKeys; //sb protocol sends as a byte so max of 255 | ||
} | ||
|
||
public class KeyData | ||
{ | ||
public byte Name; | ||
public byte Type; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Servers/NATNegotiation/Handler/CommandHandler/AddressHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using GameSpyLib.Abstraction.Interface; | ||
using NATNegotiation.Abstraction.BaseClass; | ||
using NATNegotiation.Entity.Enumerate; | ||
using NATNegotiation.Entity.Structure.Request; | ||
using NATNegotiation.Entity.Structure.Response; | ||
|
||
namespace NATNegotiation.Handler.CommandHandler | ||
{ | ||
public class AddressCheckHandler : NNCommandHandlerBase | ||
{ | ||
protected new AddressRequest _request; | ||
public AddressCheckHandler(ISession session, IRequest request) : base(session, request) | ||
{ | ||
_request = (AddressRequest)request; | ||
} | ||
|
||
protected override void ConstructResponse() | ||
{ | ||
_sendingBuffer = new AddressResponse(_request, _session.RemoteEndPoint).BuildResponse(); | ||
|
||
|
||
_session.UserInfo.SetIsGotAddressCheckPacketFlag(). | ||
UpdateLastPacketReceiveTime(); | ||
} | ||
} | ||
} |
Oops, something went wrong.