Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Mar 21, 2024
1 parent afb0cee commit 04b48d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches:
- main
- nm/read-proxy-protocol-header
jobs:
deploy:
concurrency: main
Expand Down Expand Up @@ -46,14 +45,14 @@ jobs:
variable-value: ${{ steps.push.outputs.docker_image }}
variable-value-required-prefix: "xmtp/node-go@sha256:"

# - name: Deploy (production)
# uses: xmtp-labs/terraform-deployer@v1
# timeout-minutes: 45
# with:
# timeout: 45m
# terraform-token: ${{ secrets.TERRAFORM_TOKEN }}
# terraform-org: xmtp
# terraform-workspace: production
# variable-name: xmtp_node_image
# variable-value: ${{ steps.push.outputs.docker_image }}
# variable-value-required-prefix: "xmtp/node-go@sha256:"
- name: Deploy (production)
uses: xmtp-labs/terraform-deployer@v1
timeout-minutes: 45
with:
timeout: 45m
terraform-token: ${{ secrets.TERRAFORM_TOKEN }}
terraform-org: xmtp
terraform-workspace: production
variable-name: xmtp_node_image
variable-value: ${{ steps.push.outputs.docker_image }}
variable-value-required-prefix: "xmtp/node-go@sha256:"
11 changes: 6 additions & 5 deletions pkg/api/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,12 @@ func (wa *WalletAuthorizer) applyLimits(ctx context.Context, fullMethod string,
// * for other authorization failure return status.Errorf(codes.PermissionDenied, ...)
_, method := splitMethodName(fullMethod)

ip := clientIPFromContext(ctx)
ip := wa.clientIPFromContext(ctx)
if len(ip) == 0 {
// requests without an IP address are bucketed together as "ip_unknown"
ip = "ip_unknown"
wa.Log.Warn("no ip found", logging.String("method", fullMethod))
}
// TODO: Remove this noisy log
wa.Log.Info("got client IP", logging.String("client_ip", ip), logging.String("method", fullMethod))

// with no wallet apply regular limits
var isPriority bool
Expand Down Expand Up @@ -237,13 +236,15 @@ func allowedToPublish(topic string, wallet types.WalletAddr) bool {
return true
}

func clientIPFromContext(ctx context.Context) string {
func (wa *WalletAuthorizer) clientIPFromContext(ctx context.Context) string {
md, _ := metadata.FromIncomingContext(ctx)
vals := md.Get("x-forwarded-for")
if len(vals) == 0 {
p, ok := peer.FromContext(ctx)
if ok {
return p.Addr.String()
ip := p.Addr.String()
wa.Log.Info("got client IP without x-forwarded-for", logging.String("client_ip", ip))
return ip
} else {
return ""
}
Expand Down

0 comments on commit 04b48d2

Please sign in to comment.