forked from craftd/craftd
-
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.
admin: Add /ticket stuff. List: Add CD_LIST_BREAK Map: Add CD_MAP_BREAK Hash: Add CD_HASH_BREAK Server: Added some anti DoS stuff.
- Loading branch information
Showing
12 changed files
with
224 additions
and
27 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 |
---|---|---|
|
@@ -11,7 +11,8 @@ | |
}, | ||
|
||
"port": 25565, | ||
"backlog": 16 | ||
"backlog": 16, | ||
"simultaneous": 3 | ||
}, | ||
|
||
"workers": 2, | ||
|
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,49 @@ | ||
#! /usr/bin/env ruby | ||
require 'socket' | ||
require 'thread' | ||
|
||
HOST, PORT = ARGV.shift.split(':') + [25565] | ||
COUNT = ARGV.shift || 2000 | ||
|
||
sockets = Class.new(Array) { | ||
def initialize (number) | ||
@number = number | ||
end | ||
|
||
def spawn | ||
self.each {|s| | ||
self.delete(s) if s.closed? | ||
} | ||
|
||
to_spawn = @number - self.length | ||
|
||
if to_spawn > 0 | ||
puts "Spawning #{to_spawn} fake connections" | ||
|
||
1.upto(to_spawn) { | ||
socket = TCPSocket.new(HOST, PORT) | ||
socket.write_nonblock("\x02\xff\xff") | ||
|
||
self << socket | ||
} | ||
end | ||
end | ||
}.new(COUNT) | ||
|
||
thread = Thread.new { | ||
loop do | ||
sockets.each {|socket| | ||
begin | ||
socket.write_nonblock((rand * 255).floor.chr) | ||
rescue Exception => e | ||
socket.close rescue nil | ||
end | ||
} | ||
|
||
begin; sockets.spawn; rescue; break; end | ||
|
||
sleep 0.5 | ||
end | ||
} | ||
|
||
thread.join |
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 |
---|---|---|
|
@@ -44,6 +44,7 @@ typedef struct _CDConfig { | |
|
||
uint16_t port; | ||
int backlog; | ||
uint8_t simultaneous; | ||
} connection; | ||
|
||
struct { | ||
|
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
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
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
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
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
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
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
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
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