()
| 44 | } |
| 45 | |
| 46 | func (token *Token) GetIpLimitsMap() map[string]any { |
| 47 | // delete empty spaces |
| 48 | //split with \n |
| 49 | ipLimitsMap := make(map[string]any) |
| 50 | if token.AllowIps == nil { |
| 51 | return ipLimitsMap |
| 52 | } |
| 53 | cleanIps := strings.ReplaceAll(*token.AllowIps, " ", "") |
| 54 | if cleanIps == "" { |
| 55 | return ipLimitsMap |
| 56 | } |
| 57 | ips := strings.Split(cleanIps, "\n") |
| 58 | for _, ip := range ips { |
| 59 | ip = strings.TrimSpace(ip) |
| 60 | ip = strings.ReplaceAll(ip, ",", "") |
| 61 | if common.IsIP(ip) { |
| 62 | ipLimitsMap[ip] = true |
| 63 | } |
| 64 | } |
| 65 | return ipLimitsMap |
| 66 | } |
| 67 | |
| 68 | func GetAllUserTokens(userId int, startIdx int, num int) ([]*Token, error) { |
| 69 | var tokens []*Token |
no test coverage detected