• R/O
  • HTTP
  • SSH
  • HTTPS

shogi-server: コミット

shogi-server source


コミットメタ情報

リビジョン990d522aa01222ddfc0ad50a6915da00ba44629b (tree)
日時2016-11-26 18:01:39
作者Daigo Moriwaki <daigo@debi...>
コミッターDaigo Moriwaki

ログメッセージ

Fix #36821: Allow to customize maximum lenght of a login indentifier

変更サマリ

差分

--- a/changelog
+++ b/changelog
@@ -1,3 +1,13 @@
1+2016-11-26 Daigo Moriwaki <daigo at debian dot org>
2+
3+ * [shogi-server] Allow to customize maximum lenght of a login indentifier
4+ (Closes #36821)
5+ - The current maximum length of a login identifier is 32. Some
6+ private uses require longer player names to distinguish each other
7+ by specifying randomly generated tokens. It would of help to add a
8+ new command line option --max-identifier to overwrite the default
9+ maximum length.
10+
111 2016-04-09 Daigo Moriwaki <daigo at debian dot org>
212
313 * utils/eval_graph.rb
--- a/shogi-server
+++ b/shogi-server
@@ -82,6 +82,8 @@ OPTIONS
8282 Least time in second per move: 0, 1 (default 1).
8383 - 0: The new rule that CSA introduced in November 2014.
8484 - 1: The old rule before it.
85+ --max-identifier n
86+ maximum length of an identifier
8587 --max-moves n
8688 when a game with the n-th move played does not end, make the game a draw.
8789 Default 256. 0 disables this feature.
@@ -206,6 +208,7 @@ def parse_command_line
206208 ["--daemon", GetoptLong::REQUIRED_ARGUMENT],
207209 ["--floodgate-games", GetoptLong::REQUIRED_ARGUMENT],
208210 ["--least-time-per-move", GetoptLong::REQUIRED_ARGUMENT],
211+ ["--max-identifier", GetoptLong::REQUIRED_ARGUMENT],
209212 ["--max-moves", GetoptLong::REQUIRED_ARGUMENT],
210213 ["--pid-file", GetoptLong::REQUIRED_ARGUMENT],
211214 ["--player-log-dir", GetoptLong::REQUIRED_ARGUMENT])
@@ -281,6 +284,9 @@ def check_command_line
281284 $options["max-moves"] ||= ShogiServer::Default_Max_Moves
282285 $options["max-moves"] = $options["max-moves"].to_i
283286
287+ $options["max-identifier"] ||= ShogiServer::Default_Max_Identifier_Length
288+ $options["max-identifier"] = $options["max-identifier"].to_i
289+
284290 $options["least-time-per-move"] ||= ShogiServer::Default_Least_Time_Per_Move
285291 $options["least-time-per-move"] = $options["least-time-per-move"].to_i
286292 end
--- a/shogi_server.rb
+++ b/shogi_server.rb
@@ -45,14 +45,14 @@ require 'shogi_server/buoy'
4545
4646 module ShogiServer # for a namespace
4747
48-Max_Identifier_Length = 32
48+Default_Max_Identifier_Length = 32
4949 Default_Timeout = 60 # for single socket operation
5050 Default_Game_Name = "default-1500-0"
5151 Default_Max_Moves = 256
5252 Default_Least_Time_Per_Move = 0
5353 One_Time = 10
5454 Login_Time = 300 # time for LOGIN
55-Revision = "20160409"
55+Revision = "20161126"
5656
5757 RELOAD_FILES = ["shogi_server/league/floodgate.rb",
5858 "shogi_server/league/persistent.rb",
--- a/shogi_server/login.rb
+++ b/shogi_server/login.rb
@@ -79,7 +79,8 @@ class Login
7979 end
8080
8181 def Login.good_identifier?(str)
82- if str =~ /\A[\w@\-\.]{1,#{Max_Identifier_Length}}\z/
82+ max = $options["max-identifier"]
83+ if str =~ /\A[\w@\-\.]{1,#{max}}\z/
8384 return true
8485 else
8586 return false
--- a/test/TC_game_least_0.rb
+++ b/test/TC_game_least_0.rb
@@ -5,7 +5,7 @@ require 'shogi_server/board'
55 require 'shogi_server/game'
66 require 'shogi_server/player'
77
8-$options = {}
8+$options ||= {}
99 $options["least-time-per-move"] = 0
1010 $options["max-moves"] = 256
1111
--- a/test/TC_login.rb
+++ b/test/TC_login.rb
@@ -5,6 +5,8 @@ require 'shogi_server/player'
55 require 'shogi_server/login'
66 require 'shogi_server/handicapped_boards'
77
8+$options ||= {}
9+
810 class ShogiServer::BasicPlayer
911 attr_accessor :protocol
1012 end
@@ -18,12 +20,23 @@ class TestLogin < Test::Unit::TestCase
1820 @p_x1.name = "hoge"
1921 @csa = ShogiServer::LoginCSA.new(@p_csa,"floodgate-900-0,xyz")
2022 @x1 = ShogiServer::Loginx1.new(@p_x1, "xyz")
23+
24+ $options["max-identifier"] = ShogiServer::Default_Max_Identifier_Length
2125 end
2226
2327 def test_player_id
2428 assert(@p_x1.player_id == @p_csa.player_id)
2529 end
2630
31+ def test_good_identifier
32+ assert_true(ShogiServer::Login::good_identifier? "hoge")
33+ assert_true(ShogiServer::Login::good_identifier? "12345678901234567890123456789012")
34+
35+ $options["max-identifier"] = 128
36+ assert_true(ShogiServer::Login::good_identifier? "0"*128)
37+ assert_false(ShogiServer::Login::good_identifier? "0"*129)
38+ end
39+
2740 def test_login_factory_x1
2841 player = ShogiServer::BasicPlayer.new
2942 player.name = "hoge"
@@ -97,7 +110,7 @@ class TestLogin < Test::Unit::TestCase
97110 assert_equal("floodgate-900-0", login.gamename)
98111 end
99112
100- def test_login_factory_csa_with_white
113+ def test_login_factory_csa_with_white_fischer
101114 player = ShogiServer::BasicPlayer.new
102115 player.name = "hoge"
103116 login = ShogiServer::Login::factory("LOGIN hoge floodgate-900-10F-W,xyz", player)
旧リポジトリブラウザで表示