Skip to content

Commit f477d8e

Browse files
committed
Remove java domain proxy.
1 parent b249270 commit f477d8e

File tree

32 files changed

+44
-1433
lines changed

32 files changed

+44
-1433
lines changed

.tekton/domain-proxy-pull-request.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ spec:
2727
- name: image-expires-after
2828
value: 5d
2929
- name: dockerfile
30-
value: /java-components/domain-proxy/src/main/docker/Dockerfile.all-in-one
30+
value: /domain-proxy/Dockerfile.all-in-one
3131
- name: path-context
32-
value: java-components
32+
value: domain-proxy
3333
pipelineSpec:
3434
finally:
3535
- name: show-sbom

.tekton/domain-proxy-push.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ spec:
2424
- name: output-image
2525
value: quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/domain-proxy:{{revision}}
2626
- name: dockerfile
27-
value: /java-components/domain-proxy/src/main/docker/Dockerfile.all-in-one
27+
value: /domain-proxy/Dockerfile.all-in-one
2828
- name: path-context
29-
value: java-components
29+
value: domain-proxy
3030
pipelineSpec:
3131
finally:
3232
- name: show-sbom

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ dev-image-controller:
6969
docker push quay.io/$(QUAY_USERNAME)/hacbs-jvm-controller:"$${JBS_QUAY_IMAGE_TAG:-dev}"
7070

7171
dev: dev-image-controller
72-
cd java-components && mvn clean install -Dlocal -DskipTests -Ddev && cd ../domain-proxy-go && go build -o domain-proxy-server domain_proxy_server.go common.go && go build -o domain-proxy-client domain_proxy_client.go common.go && cd ..
73-
docker build . -f domain-proxy-go/Dockerfile.local -t quay.io/$(QUAY_USERNAME)/hacbs-jvm-domain-proxy:"$${JBS_QUAY_IMAGE_TAG:-dev}"
72+
cd java-components && mvn clean install -Dlocal -DskipTests -Ddev
73+
cd domain-proxy && go build -o domain-proxy-server domain_proxy_server.go common.go && go build -o domain-proxy-client domain_proxy_client.go common.go
74+
docker build . -f domain-proxy/Dockerfile.local -t quay.io/$(QUAY_USERNAME)/hacbs-jvm-domain-proxy:"$${JBS_QUAY_IMAGE_TAG:-dev}"
7475
docker push quay.io/$(QUAY_USERNAME)/hacbs-jvm-domain-proxy:"$${JBS_QUAY_IMAGE_TAG:-dev}"
7576

7677
dev-openshift: dev

domain-proxy-go/go.mod

Lines changed: 0 additions & 3 deletions
This file was deleted.

domain-proxy-go/Dockerfile.all-in-one renamed to domain-proxy/Dockerfile.all-in-one

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ USER 0
1111
RUN microdnf install -y iproute
1212
WORKDIR /work/
1313

14-
COPY --from=builder /work/domain-proxy-go/domain-proxy-server /app/domain-proxy-server
15-
COPY --from=builder /work/domain-proxy-go/domain-proxy-client /app/domain-proxy-client
14+
COPY --from=builder /work/domain-proxy/domain-proxy-server /app/domain-proxy-server
15+
COPY --from=builder /work/domain-proxy/domain-proxy-client /app/domain-proxy-client
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM quay.io/konflux-ci/buildah-task:latest@sha256:5cbd487022fb7ac476cbfdea25513b810f7e343ec48f89dc6a4e8c3c39fa37a2
22
USER 0
33
RUN microdnf install -y iproute
4-
COPY domain-proxy-go/domain-proxy-server /app/domain-proxy-server
5-
COPY domain-proxy-go/domain-proxy-client /app/domain-proxy-client
4+
COPY domain-proxy/domain-proxy-server /app/domain-proxy-server
5+
COPY domain-proxy/domain-proxy-client /app/domain-proxy-client
66

domain-proxy-go/common.go renamed to domain-proxy/common.go

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"errors"
45
"io"
56
"log"
67
"net"
@@ -19,51 +20,55 @@ const (
1920
ConnectionTimeoutKey = "CONNECTION_TIMEOUT"
2021
DefaultConnectionTimeout = 1000 * time.Millisecond
2122
IdleTimeoutKey = "IDLE_TIMEOUT"
22-
DefaultIdleTimeout = 10000 * time.Millisecond
23+
DefaultIdleTimeout = 1000 * time.Millisecond
2324
)
2425

25-
func ChannelToChannelBiDirectionalHandler(leftConn, rightConn net.Conn, byteBufferSize int, idleTimeout time.Duration, executor *sync.WaitGroup) {
26+
func BiDirectionalTransfer(leftConn, rightConn net.Conn, byteBufferSize int, idleTimeout time.Duration, executor *sync.WaitGroup) {
2627
defer executor.Done()
28+
defer CloseConnections(leftConn, rightConn)
2729
done := make(chan struct{})
28-
var mutex sync.Mutex
29-
go Transfer(leftConn, rightConn, done, byteBufferSize, idleTimeout, &mutex)
30-
go Transfer(rightConn, leftConn, done, byteBufferSize, idleTimeout, &mutex)
30+
leftConn.SetDeadline(time.Now().Add(idleTimeout))
31+
rightConn.SetDeadline(time.Now().Add(idleTimeout))
32+
go Transfer(leftConn, rightConn, done, byteBufferSize, idleTimeout)
33+
go Transfer(rightConn, leftConn, done, byteBufferSize, idleTimeout)
3134
<-done
3235
<-done
33-
CloseConnections(leftConn, rightConn)
3436
}
3537

36-
func Transfer(targetConn, sourceConn net.Conn, done chan struct{}, bufferSize int, idleTimeout time.Duration, mutex *sync.Mutex) {
38+
func Transfer(targetConn, sourceConn net.Conn, done chan struct{}, bufferSize int, idleTimeout time.Duration) {
3739
defer func() {
3840
done <- struct{}{}
3941
}()
4042
buf := make([]byte, bufferSize)
41-
mutex.Lock()
42-
sourceConn.SetDeadline(time.Now().Add(idleTimeout))
43-
targetConn.SetDeadline(time.Now().Add(idleTimeout))
44-
mutex.Unlock()
4543
for {
4644
n, err := sourceConn.Read(buf)
4745
if err != nil {
48-
if err != io.EOF {
49-
log.Printf("Error reading from source: %v", err)
50-
}
46+
handleConnectionError(err)
5147
return
52-
}
53-
if n > 0 {
54-
mutex.Lock()
55-
sourceConn.SetDeadline(time.Now().Add(idleTimeout))
56-
targetConn.SetDeadline(time.Now().Add(idleTimeout))
57-
mutex.Unlock()
58-
_, err = targetConn.Write(buf[:n])
48+
} else if n > 0 {
49+
log.Printf("%d bytes read", n)
50+
sourceConn.SetReadDeadline(time.Now().Add(idleTimeout))
51+
n, err = targetConn.Write(buf[:n])
5952
if err != nil {
60-
log.Printf("Error writing to target: %v", err)
53+
handleConnectionError(err)
6154
return
55+
} else if n > 0 {
56+
log.Printf("%d bytes written", n)
57+
targetConn.SetWriteDeadline(time.Now().Add(idleTimeout))
6258
}
6359
}
6460
}
6561
}
6662

63+
func handleConnectionError(err error) {
64+
var netErr net.Error
65+
if errors.As(err, &netErr) && netErr.Timeout() {
66+
log.Printf("Connection timed out")
67+
} else if err != io.EOF {
68+
log.Printf("Error using connection: %v", err)
69+
}
70+
}
71+
6772
func CloseConnections(leftConn, rightConn net.Conn) {
6873
if leftConn != nil {
6974
leftConn.Close()

domain-proxy-go/domain_proxy_client.go renamed to domain-proxy/domain_proxy_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (dpc *DomainProxyClient) startClient() {
7373
continue
7474
}
7575
dpc.executor.Add(1)
76-
go ChannelToChannelBiDirectionalHandler(serverConn, domainConn, dpc.byteBufferSize, dpc.idleTimeout, dpc.executor)
76+
go BiDirectionalTransfer(serverConn, domainConn, dpc.byteBufferSize, dpc.idleTimeout, dpc.executor)
7777
}
7878
}
7979

domain-proxy-go/domain_proxy_server.go renamed to domain-proxy/domain_proxy_server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func (dps *DomainProxyServer) handleRequest(conn net.Conn) {
100100
return
101101
}
102102
w := &responseWriter{conn: conn}
103+
conn.SetDeadline(time.Now().Add(dps.idleTimeout))
103104
if req.Method == http.MethodConnect {
104105
dps.handleHttpsRequest(conn, w, req)
105106
} else {
@@ -173,7 +174,7 @@ func (dps *DomainProxyServer) handleHttpsRequest(sourceConn net.Conn, w http.Res
173174
return
174175
}
175176
dps.executor.Add(1)
176-
go ChannelToChannelBiDirectionalHandler(sourceConn, targetConn, dps.byteBufferSize, dps.idleTimeout, dps.executor)
177+
go BiDirectionalTransfer(sourceConn, targetConn, dps.byteBufferSize, dps.idleTimeout, dps.executor)
177178
}
178179
}
179180

domain-proxy/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module domain-proxy
2+
3+
go 1.23

0 commit comments

Comments
 (0)