Skip to content

Commit

Permalink
Merge pull request #47 from deflect-ca/hotfix/minor-fix
Browse files Browse the repository at this point in the history
Remove unused logs
  • Loading branch information
jeremy5189 authored Oct 4, 2023
2 parents e60128b + 6ab0bdf commit 7e87da9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ WORKDIR /opt/banjax

# To enable live reload for dev, uncomment the following lines
#COPY ./.air.toml /opt/banjax/
# go mod edit -replace github.com/codahale/hdrhistogram=github.com/HdrHistogram/[email protected]
#RUN go mod edit -replace github.com/imdario/mergo=dario.cat/[email protected]
#RUN go get -u github.com/cosmtrek/[email protected]
#RUN mkdir -p /opt/banjax/tmp
Expand Down
2 changes: 1 addition & 1 deletion internal/challenge_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func ValidateExpirationAndHmac(secretKey string,

func ParseCookie(cookieString string, clientIp string) ([]byte, []byte, []byte, error) {
cookieBytes := make([]byte, 20+32+8)
log.Printf("ParseCookie[%s]: cookieString: %s", clientIp, cookieString)
// log.Printf("ParseCookie[%s]: cookieString: %s", clientIp, cookieString)

cookieBytes, err := base64.StdEncoding.DecodeString(cookieString)
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions internal/session_cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"log"
"math/rand"
"strconv"
"strings"
Expand Down Expand Up @@ -115,21 +116,21 @@ func sessionCookieEndPoint(c *gin.Context, config *Config) error {
// cookie exists, validate it
validateErr := validateSessionCookie(dsc, config.SessionCookieHmacSecret, time.Now(), clientIp)
if validateErr == nil {
// cookie is valid, do nothing
fmt.Printf("[%s] cookie %s is valid, report dsc_new=false\n", clientIp, dsc)
// cookie is valid, do not attach cookie but only report dsc_new=false
// fmt.Printf("DSC: [%s] cookie %s is valid, report dsc_new=false\n", clientIp, dsc)
attachSessionCookie(c, config, dsc, false)
} else {
// cookie is invalid, create a new one
newDsc := newSessionCookie(config.SessionCookieHmacSecret, config.SessionCookieTtlSeconds, clientIp)
fmt.Printf("[%s] cookie %s is not valid, issue new: %s\n", clientIp, dsc, newDsc)
log.Printf("DSC: [%s] cookie %s is not valid, issue new: %s\n", clientIp, dsc, newDsc)
attachSessionCookie(c, config, newDsc, true)
}
return nil
}

// no cookie, create a new one
newDsc := newSessionCookie(config.SessionCookieHmacSecret, config.SessionCookieTtlSeconds, clientIp)
fmt.Printf("[%s] issue new cookie: %s\n", clientIp, newDsc)
// fmt.Printf("DSC: [%s] issue new cookie: %s\n", clientIp, newDsc)
attachSessionCookie(c, config, newDsc, true)
return nil
}
Expand Down

0 comments on commit 7e87da9

Please sign in to comment.