(logger *zap.Logger, req *http.Request, destPort uint, opts models.OutgoingOptions)
| 181 | } |
| 182 | |
| 183 | func IsPassThrough(logger *zap.Logger, req *http.Request, destPort uint, opts models.OutgoingOptions) bool { |
| 184 | passThrough := false |
| 185 | |
| 186 | for _, bypass := range opts.Rules { |
| 187 | if bypass.Host != "" { |
| 188 | regex, err := regexp.Compile(bypass.Host) |
| 189 | if err != nil { |
| 190 | LogError(logger, err, "failed to compile the host regex", zap.Any("metadata", GetReqMeta(req))) |
| 191 | continue |
| 192 | } |
| 193 | passThrough = regex.MatchString(req.Host) |
| 194 | if !passThrough { |
| 195 | continue |
| 196 | } |
| 197 | } |
| 198 | if bypass.Path != "" { |
| 199 | regex, err := regexp.Compile(bypass.Path) |
| 200 | if err != nil { |
| 201 | LogError(logger, err, "failed to compile the path regex", zap.Any("metadata", GetReqMeta(req))) |
| 202 | continue |
| 203 | } |
| 204 | passThrough = regex.MatchString(req.URL.String()) |
| 205 | if !passThrough { |
| 206 | continue |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | if passThrough { |
| 211 | if bypass.Port == 0 || bypass.Port == destPort { |
| 212 | return true |
| 213 | } |
| 214 | passThrough = false |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | return passThrough |
| 219 | } |
| 220 | |
| 221 | func kebabToCamel(s string) string { |
| 222 | parts := strings.Split(s, "-") |
no test coverage detected