[GitHub] [trafficcontrol] zrhoffman opened a new pull request, #7165: arm64 support for Dev CiaB's prebuilt trafficserver image
zrhoffman opened a new pull request, #7165: URL: https://github.com/apache/trafficcontrol/pull/7165 This PR adds `linux/arm64` support to the `ghcr.io/apache/trafficcontrol/ci/trafficserver-alpine` image which makes the CDN in a Box for Developers `t3c` image work for users on `aarch64` machines, like M1 Macs. This PR also makes it so that PRs and commits changing the `.env` file does not necessarily trigger rebuilding the `ghcr.io/apache/trafficcontrol/ci/trafficserver-alpine` image, it's only rebuilt when the `ATS_VERSION` line in the `.env` file changes (and when the workflow file or the container files are changed). ## Which Traffic Control components are affected by this PR? - Dev CDN in a Box - Automation - GitHub Container Registry ## What is the best way to verify this PR? ## PR submission checklist - [x] This PR has tests - [x] Added comments explaining unintuitive parts - [ ] This PR has a CHANGELOG.md entry - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://apache.org/security) for details) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] shamrickus opened a new pull request, #7164: Pin node version in dev ciab TP/TPv2
shamrickus opened a new pull request, #7164: URL: https://github.com/apache/trafficcontrol/pull/7164 Currently the TP/TPv2 dev containers have issues starting due to node/npm versioning. `node:alpine` uses the latest node which currently is v19, many of our dependencies don't support this version causing the install to fail. This PR pins the node to version 14. Node 14 is in maintenance mode as of [two weeks ago](https://github.com/nodejs/release#release-schedule), so whenever angular in tpv2 is updated these can be bumped to 16. ## Which Traffic Control components are affected by this PR? - CDN in a Box (dev) ## What is the best way to verify this PR? Verify the TP/TPv2 dev containers are able to startup. The containers should also not complain about node version mismatch. ## PR submission checklist - [x] This PR has tests - [x] This PR has documentation - [x] This PR has a CHANGELOG.md entry - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://apache.org/security) for details) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] ezelkow1 commented on a diff in pull request #7161: DTP open sourcing
ezelkow1 commented on code in PR #7161: URL: https://github.com/apache/trafficcontrol/pull/7161#discussion_r1009843462 ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,144 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder struct { + http.ResponseWriter + + Status int + HeaderBytes int64 + ContentBytes int64 +} + +func (rec *LogRecorder) WriteHeader(code int) { + rec.Status = code + rec.ResponseWriter.WriteHeader(code) +} + +func (rec *LogRecorder) Write(bytes []byte) (int, error) { + rec.ContentBytes += int64(len(bytes)) + return rec.ResponseWriter.Write(bytes) +} + +// this is mostly for hijack +func isHandlerType(r *http.Request) bool { + if strings.Contains(r.URL.EscapedPath(), "~h.") { + return true + } else if strings.Contains(r.URL.RawQuery, "~h.") { + return true + } else { + for _, part := range r.Header[`X-Dtp`] { + if strings.Contains(part, "~h.") { + return true + } + } + } + + return false +} + +func Logger(alog *log.Logger, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + timeStart := time.Now().UnixNano() + + // the logger interferes with hijacking + if isHandlerType(r) { + next.ServeHTTP(w, r) + url := strings.Replace(r.URL.String(), "\n", "", -1) + url = strings.Replace(url, "\r", "", -1) + ua := strings.Replace(r.UserAgent(), "\n", "", -1) + ua = strings.Replace(ua, "\r", "", -1) + thisRange := strings.Replace(r.Header.Get("Range"), "\n", "", -1) + thisRange = strings.Replace(thisRange, "\r", "", -1) + alog.Printf("%.3f %s \"%s\" %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + url, + 42, // status code -- why not? + 0, // bytes + 0, // ttms + ua, + thisRange, + ) + return + } + + tlsstr := "-" + if r.TLS != nil { + tlsstr = tls.CipherSuiteName(r.TLS.CipherSuite) + } + /* + if nil != r.TLS { + tlsstr = fmt.Sprintf("0x%x", r.TLS.CipherSuite) + } + */ + + rec := LogRecorder{w, 200, 0, 0} + next.ServeHTTP(, r) + timeStop := time.Now().UnixNano() + url := strings.Replace(r.URL.String(), "\n", "", -1) + url = strings.Replace(url, "\r", "", -1) + ua := strings.Replace(r.UserAgent(), "\n", "", -1) + ua = strings.Replace(ua, "\r", "", -1) + thisRange := strings.Replace(r.Header.Get("Range"), "\n", "", -1) + thisRange = strings.Replace(thisRange, "\r", "", -1) + alog.Printf("%.3f %s \"%s\" %s %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + url, + tlsstr, + rec.Status, + rec.ContentBytes, + int64((timeStop-timeStart)/100), + ua, + thisRange, + ) + + if GlobalConfig.Log.RequestHeaders { + alog.Print(r.Header) Review Comment: dismissed (as tests)! -- This is an automated message from the Apache Git Service. To respond to the message, please log on
[GitHub] [trafficcontrol] ezelkow1 commented on a diff in pull request #7161: DTP open sourcing
ezelkow1 commented on code in PR #7161: URL: https://github.com/apache/trafficcontrol/pull/7161#discussion_r1009842717 ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,144 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder struct { + http.ResponseWriter + + Status int + HeaderBytes int64 + ContentBytes int64 +} + +func (rec *LogRecorder) WriteHeader(code int) { + rec.Status = code + rec.ResponseWriter.WriteHeader(code) +} + +func (rec *LogRecorder) Write(bytes []byte) (int, error) { + rec.ContentBytes += int64(len(bytes)) + return rec.ResponseWriter.Write(bytes) +} + +// this is mostly for hijack +func isHandlerType(r *http.Request) bool { + if strings.Contains(r.URL.EscapedPath(), "~h.") { + return true + } else if strings.Contains(r.URL.RawQuery, "~h.") { + return true + } else { + for _, part := range r.Header[`X-Dtp`] { + if strings.Contains(part, "~h.") { + return true + } + } + } + + return false +} + +func Logger(alog *log.Logger, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + timeStart := time.Now().UnixNano() + + // the logger interferes with hijacking + if isHandlerType(r) { + next.ServeHTTP(w, r) + url := strings.Replace(r.URL.String(), "\n", "", -1) + url = strings.Replace(url, "\r", "", -1) + ua := strings.Replace(r.UserAgent(), "\n", "", -1) + ua = strings.Replace(ua, "\r", "", -1) + thisRange := strings.Replace(r.Header.Get("Range"), "\n", "", -1) + thisRange = strings.Replace(thisRange, "\r", "", -1) + alog.Printf("%.3f %s \"%s\" %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + url, + 42, // status code -- why not? + 0, // bytes + 0, // ttms + ua, + thisRange, + ) + return + } + + tlsstr := "-" + if r.TLS != nil { + tlsstr = tls.CipherSuiteName(r.TLS.CipherSuite) + } + /* + if nil != r.TLS { + tlsstr = fmt.Sprintf("0x%x", r.TLS.CipherSuite) + } + */ + + rec := LogRecorder{w, 200, 0, 0} + next.ServeHTTP(, r) + timeStop := time.Now().UnixNano() + url := strings.Replace(r.URL.String(), "\n", "", -1) + url = strings.Replace(url, "\r", "", -1) + ua := strings.Replace(r.UserAgent(), "\n", "", -1) + ua = strings.Replace(ua, "\r", "", -1) + thisRange := strings.Replace(r.Header.Get("Range"), "\n", "", -1) + thisRange = strings.Replace(thisRange, "\r", "", -1) + alog.Printf("%.3f %s \"%s\" %s %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + url, + tlsstr, + rec.Status, + rec.ContentBytes, + int64((timeStop-timeStart)/100), + ua, + thisRange, + ) + + if GlobalConfig.Log.RequestHeaders { + alog.Print(r.Header) + } + if GlobalConfig.Log.ResponseHeaders { + alog.Print(w.Header()) + } + })
[GitHub] [trafficcontrol] ezelkow1 commented on a diff in pull request #7161: DTP open sourcing
ezelkow1 commented on code in PR #7161: URL: https://github.com/apache/trafficcontrol/pull/7161#discussion_r1009841681 ## test/fakeOrigin/dtp/config.go: ## @@ -0,0 +1,120 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "encoding/json" + "fmt" + "net/http" + "time" +) + +type Log struct { + Access bool `json:"access"` + Pathstring `json:"path"` + RequestHeaders bool `json:"request_headers"` + ResponseHeaders bool `json:"response_headers"` +} + +type Timeout struct { + Read time.Duration `json:"read"` + Write time.Duration `json:"write"` + Idle time.Duration `json:"idle"` +} + +type Config struct { + Debug bool `json:"debug"` + EnablePprof bool `json:"enable_pprof"` + Log Log `json:"log"` + Timeout Timeout `json:"timeout"` + StallDuration time.Duration `json:"stall_duration"` +} + +func NewConfig() Config { + var cfg Config + cfg.Log.Access = true + cfg.Log.Path = "dtp.log" + cfg.Log.RequestHeaders = false + cfg.Log.ResponseHeaders = false + cfg.EnablePprof = false + cfg.Timeout.Read = time.Duration(10) * time.Second + cfg.Timeout.Write = time.Duration(10) * time.Second + cfg.Timeout.Idle = time.Duration(10) * time.Second + cfg.StallDuration = time.Duration(0) + return cfg +} + +var GlobalConfig = NewConfig() + +// handle api configuration endpoint +func ConfigHandler(w http.ResponseWriter, r *http.Request) { + { + dbghdrs := r.URL.Query().Get("debug") + if dbghdrs != "" { + fmt.Println("processing debug", dbghdrs) Review Comment: dismissed (as tests) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] ezelkow1 commented on a diff in pull request #7161: DTP open sourcing
ezelkow1 commented on code in PR #7161: URL: https://github.com/apache/trafficcontrol/pull/7161#discussion_r1009840899 ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,130 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder struct { + http.ResponseWriter + + Status int + HeaderBytes int64 + ContentBytes int64 +} + +func (rec *LogRecorder) WriteHeader(code int) { + rec.Status = code + rec.ResponseWriter.WriteHeader(code) +} + +func (rec *LogRecorder) Write(bytes []byte) (int, error) { + rec.ContentBytes += int64(len(bytes)) + return rec.ResponseWriter.Write(bytes) +} + +// this is mostly for hijack +func isHandlerType(r *http.Request) bool { + if strings.Contains(r.URL.EscapedPath(), "~h.") { + return true + } else if strings.Contains(r.URL.RawQuery, "~h.") { + return true + } else { + for _, part := range r.Header[`X-Dtp`] { + if strings.Contains(part, "~h.") { + return true + } + } + } + + return false +} + +func Logger(alog *log.Logger, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + timeStart := time.Now().UnixNano() + + // the logger interferes with hijacking + if isHandlerType(r) { + next.ServeHTTP(w, r) + alog.Printf("%.3f %s \"%s\" %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + r.URL.String(), + 42, // status code -- why not? + 0, // bytes + 0, // ttms + r.UserAgent(), + r.Header.Get("Range"), + ) + return + } + + tlsstr := "-" + if r.TLS != nil { + tlsstr = tls.CipherSuiteName(r.TLS.CipherSuite) + } + /* + if nil != r.TLS { + tlsstr = fmt.Sprintf("0x%x", r.TLS.CipherSuite) + } + */ + + rec := LogRecorder{w, 200, 0, 0} + next.ServeHTTP(, r) + timeStop := time.Now().UnixNano() + alog.Printf("%.3f %s \"%s\" %s %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + r.URL.String(), + tlsstr, + rec.Status, + rec.ContentBytes, + int64((timeStop-timeStart)/100), + r.UserAgent(), Review Comment: dismissed (as tests)! ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,130 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder
[GitHub] [trafficcontrol] ezelkow1 commented on a diff in pull request #7161: DTP open sourcing
ezelkow1 commented on code in PR #7161: URL: https://github.com/apache/trafficcontrol/pull/7161#discussion_r1009840703 ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,130 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder struct { + http.ResponseWriter + + Status int + HeaderBytes int64 + ContentBytes int64 +} + +func (rec *LogRecorder) WriteHeader(code int) { + rec.Status = code + rec.ResponseWriter.WriteHeader(code) +} + +func (rec *LogRecorder) Write(bytes []byte) (int, error) { + rec.ContentBytes += int64(len(bytes)) + return rec.ResponseWriter.Write(bytes) +} + +// this is mostly for hijack +func isHandlerType(r *http.Request) bool { + if strings.Contains(r.URL.EscapedPath(), "~h.") { + return true + } else if strings.Contains(r.URL.RawQuery, "~h.") { + return true + } else { + for _, part := range r.Header[`X-Dtp`] { + if strings.Contains(part, "~h.") { + return true + } + } + } + + return false +} + +func Logger(alog *log.Logger, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + timeStart := time.Now().UnixNano() + + // the logger interferes with hijacking + if isHandlerType(r) { + next.ServeHTTP(w, r) + alog.Printf("%.3f %s \"%s\" %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + r.URL.String(), Review Comment: dismissed (as tests)! ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,130 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder struct { + http.ResponseWriter + + Status int + HeaderBytes int64 + ContentBytes int64 +} + +func (rec *LogRecorder) WriteHeader(code int) { + rec.Status = code + rec.ResponseWriter.WriteHeader(code) +} + +func (rec *LogRecorder) Write(bytes []byte) (int, error) { + rec.ContentBytes += int64(len(bytes)) + return rec.ResponseWriter.Write(bytes) +} + +// this is mostly for hijack +func isHandlerType(r *http.Request) bool { + if strings.Contains(r.URL.EscapedPath(), "~h.") { + return true + } else if strings.Contains(r.URL.RawQuery, "~h.") { + return true + } else { + for _, part := range r.Header[`X-Dtp`] { + if strings.Contains(part, "~h.") { + return true + } + } + } + + return false +} + +func Logger(alog *log.Logger, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + timeStart := time.Now().UnixNano() + + // the logger interferes with hijacking + if isHandlerType(r) { +
[GitHub] [trafficcontrol] ezelkow1 commented on a diff in pull request #7161: DTP open sourcing
ezelkow1 commented on code in PR #7161: URL: https://github.com/apache/trafficcontrol/pull/7161#discussion_r1009840556 ## test/fakeOrigin/dtp/config.go: ## @@ -0,0 +1,120 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "encoding/json" + "fmt" + "net/http" + "time" +) + +type Log struct { + Access bool `json:"access"` + Pathstring `json:"path"` + RequestHeaders bool `json:"request_headers"` + ResponseHeaders bool `json:"response_headers"` +} + +type Timeout struct { + Read time.Duration `json:"read"` + Write time.Duration `json:"write"` + Idle time.Duration `json:"idle"` +} + +type Config struct { + Debug bool `json:"debug"` + EnablePprof bool `json:"enable_pprof"` + Log Log `json:"log"` + Timeout Timeout `json:"timeout"` + StallDuration time.Duration `json:"stall_duration"` +} + +func NewConfig() Config { + var cfg Config + cfg.Log.Access = true + cfg.Log.Path = "dtp.log" + cfg.Log.RequestHeaders = false + cfg.Log.ResponseHeaders = false + cfg.EnablePprof = false + cfg.Timeout.Read = time.Duration(10) * time.Second + cfg.Timeout.Write = time.Duration(10) * time.Second + cfg.Timeout.Idle = time.Duration(10) * time.Second + cfg.StallDuration = time.Duration(0) + return cfg +} + +var GlobalConfig = NewConfig() + +// handle api configuration endpoint +func ConfigHandler(w http.ResponseWriter, r *http.Request) { + { + dbghdrs := r.URL.Query().Get("debug") + if dbghdrs != "" { + fmt.Println("processing debug", dbghdrs) Review Comment: dismissed (as tests)! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] github-code-scanning[bot] commented on a diff in pull request #7161: DTP open sourcing
github-code-scanning[bot] commented on code in PR #7161: URL: https://github.com/apache/trafficcontrol/pull/7161#discussion_r1009840274 ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,130 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder struct { + http.ResponseWriter + + Status int + HeaderBytes int64 + ContentBytes int64 +} + +func (rec *LogRecorder) WriteHeader(code int) { + rec.Status = code + rec.ResponseWriter.WriteHeader(code) +} + +func (rec *LogRecorder) Write(bytes []byte) (int, error) { + rec.ContentBytes += int64(len(bytes)) + return rec.ResponseWriter.Write(bytes) +} + +// this is mostly for hijack +func isHandlerType(r *http.Request) bool { + if strings.Contains(r.URL.EscapedPath(), "~h.") { + return true + } else if strings.Contains(r.URL.RawQuery, "~h.") { + return true + } else { + for _, part := range r.Header[`X-Dtp`] { + if strings.Contains(part, "~h.") { + return true + } + } + } + + return false +} + +func Logger(alog *log.Logger, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + timeStart := time.Now().UnixNano() + + // the logger interferes with hijacking + if isHandlerType(r) { + next.ServeHTTP(w, r) + alog.Printf("%.3f %s \"%s\" %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + r.URL.String(), Review Comment: ## Log entries created from user input Log entry depends on a [user-provided value](1). [Show more details](https://github.com/apache/trafficcontrol/security/code-scanning/238) ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,130 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder struct { + http.ResponseWriter + + Status int + HeaderBytes int64 + ContentBytes int64 +} + +func (rec *LogRecorder) WriteHeader(code int) { + rec.Status = code + rec.ResponseWriter.WriteHeader(code) +} + +func (rec *LogRecorder) Write(bytes []byte) (int, error) { + rec.ContentBytes += int64(len(bytes)) + return rec.ResponseWriter.Write(bytes) +} + +// this is mostly for hijack +func isHandlerType(r *http.Request) bool { + if strings.Contains(r.URL.EscapedPath(), "~h.") { + return true + } else if strings.Contains(r.URL.RawQuery, "~h.") { + return true + } else { + for _, part := range r.Header[`X-Dtp`] { + if strings.Contains(part, "~h.") { + return true + } + } + } + + return false +} + +func Logger(alog *log.Logger, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request)
[GitHub] [trafficcontrol] rimashah25 commented on a diff in pull request #7099: Delivery Service Active Flag Rework
rimashah25 commented on code in PR #7099: URL: https://github.com/apache/trafficcontrol/pull/7099#discussion_r1009828166 ## traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go: ## @@ -138,7 +162,7 @@ func CreateV30(w http.ResponseWriter, r *http.Request) { ds := tc.DeliveryServiceV30{} if err := json.NewDecoder(r.Body).Decode(); err != nil { - api.HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest, errors.New("decoding: "+err.Error()), nil) + api.HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest, fmt.Errorf("decoding: %w", err), nil) Review Comment: Ok, I like that you are taking care of it in each of your PR but I feel that is a bit of scope creep. Because this is refactor(necessary) but I am not a 100% sure in a PR this big it should have been included. I f you want, create an issue to tackle this as part of tech-debt and we can take care of it at one go. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] ezelkow1 commented on a diff in pull request #7161: DTP open sourcing
ezelkow1 commented on code in PR #7161: URL: https://github.com/apache/trafficcontrol/pull/7161#discussion_r1009826559 ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,144 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder struct { + http.ResponseWriter + + Status int + HeaderBytes int64 + ContentBytes int64 +} + +func (rec *LogRecorder) WriteHeader(code int) { + rec.Status = code + rec.ResponseWriter.WriteHeader(code) +} + +func (rec *LogRecorder) Write(bytes []byte) (int, error) { + rec.ContentBytes += int64(len(bytes)) + return rec.ResponseWriter.Write(bytes) Review Comment: dismissed (as tests) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] ezelkow1 commented on a diff in pull request #7161: DTP open sourcing
ezelkow1 commented on code in PR #7161: URL: https://github.com/apache/trafficcontrol/pull/7161#discussion_r1009827162 ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,144 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder struct { + http.ResponseWriter + + Status int + HeaderBytes int64 + ContentBytes int64 +} + +func (rec *LogRecorder) WriteHeader(code int) { + rec.Status = code + rec.ResponseWriter.WriteHeader(code) +} + +func (rec *LogRecorder) Write(bytes []byte) (int, error) { + rec.ContentBytes += int64(len(bytes)) + return rec.ResponseWriter.Write(bytes) +} + +// this is mostly for hijack +func isHandlerType(r *http.Request) bool { + if strings.Contains(r.URL.EscapedPath(), "~h.") { + return true + } else if strings.Contains(r.URL.RawQuery, "~h.") { + return true + } else { + for _, part := range r.Header[`X-Dtp`] { + if strings.Contains(part, "~h.") { + return true + } + } + } + + return false +} + +func Logger(alog *log.Logger, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + timeStart := time.Now().UnixNano() + + // the logger interferes with hijacking + if isHandlerType(r) { + next.ServeHTTP(w, r) + url := strings.Replace(r.URL.String(), "\n", "", -1) + url = strings.Replace(url, "\r", "", -1) + ua := strings.Replace(r.UserAgent(), "\n", "", -1) + ua = strings.Replace(ua, "\r", "", -1) + thisRange := strings.Replace(r.Header.Get("Range"), "\n", "", -1) + thisRange = strings.Replace(thisRange, "\r", "", -1) + alog.Printf("%.3f %s \"%s\" %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + url, + 42, // status code -- why not? + 0, // bytes + 0, // ttms + ua, + thisRange, + ) + return + } + + tlsstr := "-" + if r.TLS != nil { + tlsstr = tls.CipherSuiteName(r.TLS.CipherSuite) + } + /* + if nil != r.TLS { + tlsstr = fmt.Sprintf("0x%x", r.TLS.CipherSuite) + } + */ + + rec := LogRecorder{w, 200, 0, 0} + next.ServeHTTP(, r) + timeStop := time.Now().UnixNano() + url := strings.Replace(r.URL.String(), "\n", "", -1) + url = strings.Replace(url, "\r", "", -1) + ua := strings.Replace(r.UserAgent(), "\n", "", -1) + ua = strings.Replace(ua, "\r", "", -1) + thisRange := strings.Replace(r.Header.Get("Range"), "\n", "", -1) + thisRange = strings.Replace(thisRange, "\r", "", -1) + alog.Printf("%.3f %s \"%s\" %s %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + url, + tlsstr, + rec.Status, + rec.ContentBytes, + int64((timeStop-timeStart)/100), + ua, + thisRange, + ) + + if GlobalConfig.Log.RequestHeaders { + alog.Print(r.Header) Review Comment: dismissed (as tests)! -- This is an automated message from the Apache Git Service. To respond to the message, please log on
[GitHub] [trafficcontrol] ezelkow1 commented on a diff in pull request #7161: DTP open sourcing
ezelkow1 commented on code in PR #7161: URL: https://github.com/apache/trafficcontrol/pull/7161#discussion_r1009826299 ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,144 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder struct { + http.ResponseWriter + + Status int + HeaderBytes int64 + ContentBytes int64 +} + +func (rec *LogRecorder) WriteHeader(code int) { + rec.Status = code + rec.ResponseWriter.WriteHeader(code) +} + +func (rec *LogRecorder) Write(bytes []byte) (int, error) { + rec.ContentBytes += int64(len(bytes)) + return rec.ResponseWriter.Write(bytes) Review Comment: dismissed (as tests)! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] github-code-scanning[bot] commented on a diff in pull request #7161: DTP open sourcing
github-code-scanning[bot] commented on code in PR #7161: URL: https://github.com/apache/trafficcontrol/pull/7161#discussion_r1009807225 ## test/fakeOrigin/dtp/dtp.go: ## @@ -0,0 +1,144 @@ +package dtp + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "crypto/tls" + "fmt" + "log" + "net/http" + "strings" + "time" +) + +type LogRecorder struct { + http.ResponseWriter + + Status int + HeaderBytes int64 + ContentBytes int64 +} + +func (rec *LogRecorder) WriteHeader(code int) { + rec.Status = code + rec.ResponseWriter.WriteHeader(code) +} + +func (rec *LogRecorder) Write(bytes []byte) (int, error) { + rec.ContentBytes += int64(len(bytes)) + return rec.ResponseWriter.Write(bytes) +} + +// this is mostly for hijack +func isHandlerType(r *http.Request) bool { + if strings.Contains(r.URL.EscapedPath(), "~h.") { + return true + } else if strings.Contains(r.URL.RawQuery, "~h.") { + return true + } else { + for _, part := range r.Header[`X-Dtp`] { + if strings.Contains(part, "~h.") { + return true + } + } + } + + return false +} + +func Logger(alog *log.Logger, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + timeStart := time.Now().UnixNano() + + // the logger interferes with hijacking + if isHandlerType(r) { + next.ServeHTTP(w, r) + url := strings.Replace(r.URL.String(), "\n", "", -1) + url = strings.Replace(url, "\r", "", -1) + ua := strings.Replace(r.UserAgent(), "\n", "", -1) + ua = strings.Replace(ua, "\r", "", -1) + thisRange := strings.Replace(r.Header.Get("Range"), "\n", "", -1) + thisRange = strings.Replace(thisRange, "\r", "", -1) + alog.Printf("%.3f %s \"%s\" %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + url, + 42, // status code -- why not? + 0, // bytes + 0, // ttms + ua, + thisRange, + ) + return + } + + tlsstr := "-" + if r.TLS != nil { + tlsstr = tls.CipherSuiteName(r.TLS.CipherSuite) + } + /* + if nil != r.TLS { + tlsstr = fmt.Sprintf("0x%x", r.TLS.CipherSuite) + } + */ + + rec := LogRecorder{w, 200, 0, 0} + next.ServeHTTP(, r) + timeStop := time.Now().UnixNano() + url := strings.Replace(r.URL.String(), "\n", "", -1) + url = strings.Replace(url, "\r", "", -1) + ua := strings.Replace(r.UserAgent(), "\n", "", -1) + ua = strings.Replace(ua, "\r", "", -1) + thisRange := strings.Replace(r.Header.Get("Range"), "\n", "", -1) + thisRange = strings.Replace(thisRange, "\r", "", -1) + alog.Printf("%.3f %s \"%s\" %s %d b=%d ttms=%d uas=\"%s\" rr=\"%s\"\n", + float64(timeStart)/float64(1.e9), + r.Method, + url, + tlsstr, + rec.Status, + rec.ContentBytes, + int64((timeStop-timeStart)/100), + ua, + thisRange, + ) + + if GlobalConfig.Log.RequestHeaders { + alog.Print(r.Header) Review Comment: ## Log entries created from user input Log entry depends on a [user-provided value](1). [Show
[GitHub] [trafficcontrol] srijeet0406 closed issue #6033: Add ability to assign and remove a server capability for multiple servers at a time
srijeet0406 closed issue #6033: Add ability to assign and remove a server capability for multiple servers at a time URL: https://github.com/apache/trafficcontrol/issues/6033 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] srijeet0406 merged pull request #7079: Assign multiple servers to a capability
srijeet0406 merged PR #7079: URL: https://github.com/apache/trafficcontrol/pull/7079 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org