
Product
Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
github.com/GoogleCloudPlatform/golang-samples/run/grpc-ping
For a general introduction to gRPC on Go, see the official gRPC quickstart.
This sample presents a single server which is built to one container image.
To demonstrate service-to-service gRPC requests, this container image is deployed as two services: "ping" and "ping-upstream". ping is made public and ping-upstream is the data provider.
Build & Deploy the gRPC services:
export GOOGLE_CLOUD_PROJECT=[PROJECT_ID]
# Build and push container images.
gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT/grpc-ping
# Deploy ping service for private access.
gcloud run deploy ping-upstream --image gcr.io/$GOOGLE_CLOUD_PROJECT/grpc-ping
# Get the host name of the ping service.
PING_URL=$(gcloud run services describe ping-upstream --format='value(status.url)')
PING_DOMAIN=${PING_URL#https://}
# Deploy ping-relay service for public access.
gcloud run deploy ping --image gcr.io/$GOOGLE_CLOUD_PROJECT/grpc-ping \
--update-env-vars GRPC_PING_HOST=${PING_DOMAIN}:443 \
--allow-unauthenticated
Make a ping request:
Use the client CLI to send a request:
go run ./client -server [RELAY-SERVICE-DOMAIN]:443 -relay -message "Hello Friend"
If you later make some code changes, updating is more concise:
export GOOGLE_CLOUD_PROJECT=[PROJECT_ID]
gcloud run deploy ping --image gcr.io/$GOOGLE_CLOUD_PROJECT/grpc-ping
gcloud run deploy ping-relay --image gcr.io/$GOOGLE_CLOUD_PROJECT/grpc-ping
See below for instructions on updating the proto.
GRPC_PING_HOST
: [relay: example.com:443
; required] Ping upstream service host nanme.GRPC_PING_INSECURE
: [relay: false
] Use an insecure connection to the ping service. Primarily for local development.GRPC_PING_UNAUTHENTICATED
: [relay: false
] Make unauthenticated requests to the ping service. Primarily for local development.docker build -t grpc-ping .
cd ping
go run .
Open another terminal at the grpc-ping directory:
go run ./client -server localhost:8080 -insecure -message "Hello Friend!"
ping-j6jtwetqdq-uc.a.run.app
Start the ping service:
cd ./ping
PORT=9090 go run .
In another session, start the relay service:
cd ./relay
GRPC_PING_INSECURE=1 GRPC_PING_HOST=localhost:9090 GRPC_PING_UNAUTHENTICATED=1 \
go run .
From the grpc-ping directory use the grpc client to send a request:
go run ./client -server localhost:8080 -insecure -relay -message "Hello Relayed Friend!"
Retrieve the protoc plugin for Go:
go get -u github.com/golang/protobuf/protoc-gen-go
Modify the Protobuf by editing api/v1/message.proto
.
Regenerate the go code:
protoc \
--proto_path api/v1 \
--go_out "plugins=grpc:pkg/api/v1" \
message.proto
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.