mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-12 22:09:18 -04:00
parent
c8ee037027
commit
82675434be
@ -137,6 +137,8 @@ pub const Address = struct {
|
|||||||
port: u16,
|
port: u16,
|
||||||
isSymmetricNAT: bool = false,
|
isSymmetricNAT: bool = false,
|
||||||
|
|
||||||
|
pub const localHost = 0x0100007f;
|
||||||
|
|
||||||
pub fn format(self: Address, _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
|
pub fn format(self: Address, _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
|
||||||
if(self.isSymmetricNAT) {
|
if(self.isSymmetricNAT) {
|
||||||
try writer.print("{}.{}.{}.{}:?{}", .{self.ip & 255, self.ip >> 8 & 255, self.ip >> 16 & 255, self.ip >> 24, self.port});
|
try writer.print("{}.{}.{}.{}:?{}", .{self.ip & 255, self.ip >> 8 & 255, self.ip >> 16 & 255, self.ip >> 24, self.port});
|
||||||
@ -552,7 +554,7 @@ pub const ConnectionManager = struct { // MARK: ConnectionManager
|
|||||||
}
|
}
|
||||||
if(self.online.load(.acquire) and source.ip == self.externalAddress.ip and source.port == self.externalAddress.port) return;
|
if(self.online.load(.acquire) and source.ip == self.externalAddress.ip and source.port == self.externalAddress.port) return;
|
||||||
}
|
}
|
||||||
if(self.allowNewConnections.load(.monotonic)) {
|
if(self.allowNewConnections.load(.monotonic) or source.ip == Address.localHost) {
|
||||||
if(data.len != 0 and data[0] == @intFromEnum(Connection.ChannelId.init)) {
|
if(data.len != 0 and data[0] == @intFromEnum(Connection.ChannelId.init)) {
|
||||||
const ip = std.fmt.allocPrint(main.stackAllocator.allocator, "{}", .{source}) catch unreachable;
|
const ip = std.fmt.allocPrint(main.stackAllocator.allocator, "{}", .{source}) catch unreachable;
|
||||||
defer main.stackAllocator.free(ip);
|
defer main.stackAllocator.free(ip);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user