Skip to content

Commit

Permalink
#431,support ip segment
Browse files Browse the repository at this point in the history
  • Loading branch information
flike committed Aug 3, 2018
1 parent 81c128e commit 94a86c5
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
10 changes: 1 addition & 9 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ kingshard是一个由Go开发高性能MySQL Proxy项目,kingshard在满足基
- 支持到后端DB的最大连接数限制。
- 支持SQL日志及慢日志输出。
- 支持SQL黑名单机制。
- 支持客户端IP访问白名单机制,只有白名单中的IP才能访问kingshard。
- 支持客户端IP访问白名单机制,只有白名单中的IP才能访问kingshard(支持IP 段)
- 支持字符集设置。
- 支持last_insert_id功能。
- 支持热加载配置文件,动态修改kingshard配置项(具体参考管理端命令)。
Expand Down Expand Up @@ -78,14 +78,6 @@ kingshard是一个由Go开发高性能MySQL Proxy项目,kingshard在满足基

https://github.com/flike/kingshard/issues/148

## 技术支持Plus
Kingshard作为开源软件,会一直开源下去。但为了将kingshard项目更好地维护和发展下去,为有需要的用户提供更加全面的技术支撑服务,kingshard**推出了有偿技术服务**,主要包括但不限于以下几类:

* 咨询服务,为用户提供全方位的针对kingshard数据库中间件部署、使用、监控和告警等方面的咨询服务。
* 定制化开发服务,为用户基于kingshard提供可靠地定制化数据库中间件方案。

详情请邮件咨询:flikechen#qq.com

## 反馈
kingshard开源以来,经过不断地迭代开发,功能较为完善,稳定性有较大提升。 **目前已有超过50家公司在生产环境使用kingshard作为MySQL代理。** 如果您在使用kingshard的过程中发现BUG或者有新的功能需求,请发邮件至flikechen#qq.com与作者取得联系,或者加入QQ群(147926796)交流。
欢迎关注**后端技术快讯**公众号,有关kingshard的最新消息与后端架构设计类的文章,都会在这个公众号分享。
Expand Down
4 changes: 3 additions & 1 deletion doc/KingDoc/admin_command_introduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ admin server(opt,k,v) values('change','log_sql','on')
admin server(opt,k,v) values('change','slow_log_time','50');
#添加白名单IP
admin server(opt,k,v) values('add','allow_ip','127.0.0.1');
#支持IP或IP段
admin server(opt,k,v) values('add','allow_ip','192.168.14.0/24');
admin server(opt,k,v) values('add','allow_ip','192.168.15.1');
#删除白名单IP
admin server(opt,k,v) values('del','allow_ip','127.0.0.1');
Expand Down
2 changes: 1 addition & 1 deletion doc/KingDoc/kingshard_admin_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ URL:http://127.0.0.1:9797/api/v1/proxy/allow_ips
curl -X POST \
-H 'Content-Type: application/json' \
-u admin:admin \
-d '{"allow_ips":["127.0.0.1","192.168.0.14","192.168.0.223"]}' \
-d '{"allow_ips":["127.0.0.1","192.168.14.0/24","192.168.0.223"]}' \
127.0.0.1:9797/api/v1/proxy/allow_ips
返回结果:"ok"
Expand Down
5 changes: 3 additions & 2 deletions etc/ks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ log_sql: on
#blacklist_sql_file: /Users/flike/blacklist

# only allow this ip list ip to connect kingshard
allow_ips : 127.0.0.1,192.168.0.14
# support ip and ip segment
#allow_ips : 127.0.0.1,192.168.15.0/24

# the charset of kingshard, if you don't set this item
# the default charset of kingshard is utf8.
Expand All @@ -53,7 +54,7 @@ nodes :
password : root

# master represents a real mysql master server
master : 127.0.0.1:3307
master : 127.0.0.1:3306

# slave represents a real mysql salve server,and the number after '@' is
# read load weight of this slave.
Expand Down
7 changes: 4 additions & 3 deletions etc/unshard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ log_level : debug
#blacklist_sql_file: /Users/flike/blacklist

# only allow this ip list ip to connect kingshard
#allow_ips: 127.0.0.1
# support ip and ip segment
#allow_ips : 127.0.0.1,192.168.15.0/24

# the charset of kingshard, if you don't set this item
# the default charset of kingshard is utf8.
Expand All @@ -50,10 +51,10 @@ nodes :

# all mysql in a node must have the same user and password
user : root
password : root
password : flike

# master represents a real mysql master server
master : 127.0.0.1:3307
master : 127.0.0.1:3306

# slave represents a real mysql salve server,and the number after '@' is
# read load weight of this slave.
Expand Down
20 changes: 12 additions & 8 deletions proxy/router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import (

func TestParseRule(t *testing.T) {
var s = `
schema:
schema_list:
-
nodes: [node1, node2, node3]
default: node1
shard:
Expand All @@ -51,7 +52,7 @@ schema:
t.Fatal(err)
}

rt, err := NewRouter(&cfg.Schema)
rt, err := NewRouter(&cfg.SchemaList[0])
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -101,7 +102,8 @@ schema:

func newTestRouter() *Router {
var s = `
schema :
schema_list :
-
nodes: [node1,node2,node3,node4,node5,node6,node7,node8,node9,node10]
default: node1
shard:
Expand Down Expand Up @@ -152,7 +154,7 @@ schema :

var r *Router

r, err = NewRouter(&cfg.Schema)
r, err = NewRouter(&cfg.SchemaList[0])
if err != nil {
println(err.Error())
panic(err)
Expand All @@ -164,7 +166,8 @@ schema :
//TODO YYYY-MM-DD HH:MM:SS,YYYY-MM-DD test
func TestParseDateRule(t *testing.T) {
var s = `
schema:
schema_list:
-
nodes: [node1, node2, node3]
default: node1
shard:
Expand Down Expand Up @@ -195,7 +198,7 @@ schema:
t.Fatal(err)
}

rt, err := NewRouter(&cfg.Schema)
rt, err := NewRouter(&cfg.SchemaList[0])
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -238,7 +241,8 @@ schema:

func newTestDBRule() *Router {
var s = `
schema :
schema_list :
-
nodes: [node1,node2,node3,node4,node5,node6,node7,node8,node9,node10]
default: node1
shard:
Expand Down Expand Up @@ -268,7 +272,7 @@ schema :

var r *Router

r, err = NewRouter(&cfg.Schema)
r, err = NewRouter(&cfg.SchemaList[0])
if err != nil {
println(err.Error())
panic(err)
Expand Down
4 changes: 2 additions & 2 deletions proxy/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ nodes :
down_after_noalive : 300
idle_conns : 16
user: root
password:
password: flike
master : 127.0.0.1:3306
slave :
Expand Down Expand Up @@ -77,7 +77,7 @@ func newTestDB(t *testing.T) *backend.DB {
newTestServer(t)

f := func() {
testDB, _ = backend.Open("127.0.0.1:3306", "root", "", "kingshard", 100)
testDB, _ = backend.Open("127.0.0.1:3306", "root", "flike", "kingshard", 100)
}

testDBOnce.Do(f)
Expand Down

0 comments on commit 94a86c5

Please sign in to comment.