Skip to content

Commit

Permalink
flike#382, check date range when parsing conf
Browse files Browse the repository at this point in the history
  • Loading branch information
loxp committed Oct 31, 2018
1 parent 53d3c6c commit fe1a13f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions proxy/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ func parseRule(cfg *config.ShardConfig) (*Rule, error) {
if err != nil {
return nil, err
}
currIndexLen := len(r.SubTableIndexs)
if currIndexLen > 0 && r.SubTableIndexs[currIndexLen-1] >= dayNumbers[0] {
return nil, errors.ErrDateIllegal
}
for _, v := range dayNumbers {
r.SubTableIndexs = append(r.SubTableIndexs, v)
r.TableToNode[v] = i
Expand All @@ -206,6 +210,10 @@ func parseRule(cfg *config.ShardConfig) (*Rule, error) {
if err != nil {
return nil, err
}
currIndexLen := len(r.SubTableIndexs)
if currIndexLen > 0 && r.SubTableIndexs[currIndexLen-1] >= monthNumbers[0] {
return nil, errors.ErrDateIllegal
}
for _, v := range monthNumbers {
r.SubTableIndexs = append(r.SubTableIndexs, v)
r.TableToNode[v] = i
Expand All @@ -220,6 +228,10 @@ func parseRule(cfg *config.ShardConfig) (*Rule, error) {
if err != nil {
return nil, err
}
currIndexLen := len(r.SubTableIndexs)
if currIndexLen > 0 && r.SubTableIndexs[currIndexLen-1] >= yearNumbers[0] {
return nil, errors.ErrDateIllegal
}
for _, v := range yearNumbers {
r.TableToNode[v] = i
r.SubTableIndexs = append(r.SubTableIndexs, v)
Expand Down

0 comments on commit fe1a13f

Please sign in to comment.