Skip to content

Commit

Permalink
TLS demo files
Browse files Browse the repository at this point in the history
  • Loading branch information
alongir committed Jan 14, 2024
1 parent 82f47bc commit c0c6c7a
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 20 deletions.
3 changes: 2 additions & 1 deletion additions/outbound-tls-golang/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash

docker build . -t mertyildiran/mizutest-outbound-tls-golang:latest && docker push mertyildiran/mizutest-outbound-tls-golang:latest
# docker build . -t mertyildiran/mizutest-outbound-tls-golang:latest && docker push mertyildiran/mizutest-outbound-tls-golang:latest
docker buildx build --platform linux/amd64 -t alongir/mizutest-outbound-tls-openssl:latest . --push
Binary file added additions/outbound-tls-golang/main
Binary file not shown.
23 changes: 17 additions & 6 deletions additions/outbound-tls-golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,23 @@ func main() {
req, err := http.NewRequest("GET", "https://gorest.co.in/public/v2/not-found", nil)
if err != nil {
fmt.Println(err)
continue
}
req.Header.Set("cache-control", "no-cache")
req.Header.Set("x-powered-by", "golang")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
continue
}
// fmt.Printf("res: %+v\n", res)
defer res.Body.Close()
fmt.Printf("res: %+v\n", res)

payload := strings.NewReader(fmt.Sprintf("------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\njohn.doe.%d@example.com\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nJohn\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nmale\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"status\"\r\n\r\nactive\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", j))
req, err = http.NewRequest("POST", "https://gorest.co.in/public/v2/users", payload)
if err != nil {
fmt.Println(err)
continue
}
req.Header.Set("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW")
req.Header.Set("authorization", fmt.Sprintf("Bearer %s", ACCESS_TOKEN))
Expand All @@ -53,38 +57,45 @@ func main() {
res, err = client.Do(req)
if err != nil {
fmt.Println(err)
continue
}
// fmt.Printf("res: %+v\n", res)
defer res.Body.Close()
fmt.Printf("res: %+v\n", res)

req, err = http.NewRequest("GET", "https://gorest.co.in/public/v2/users", nil)
if err != nil {
fmt.Println(err)
continue
}
req.Header.Set("cache-control", "no-cache")
req.Header.Set("x-powered-by", "golang")
res, err = client.Do(req)
if err != nil {
fmt.Println(err)
continue
}
// fmt.Printf("res: %+v\n", res)
defer res.Body.Close()
fmt.Printf("res: %+v\n", res)

req, err = http.NewRequest("GET", "https://gorest.co.in/public/v2/posts", nil)
if err != nil {
fmt.Println(err)
continue
}
req.Header.Set("cache-control", "no-cache")
req.Header.Set("x-powered-by", "golang")
res, err = client.Do(req)
if err != nil {
fmt.Println(err)
continue
}
// fmt.Printf("res: %+v\n", res)
defer res.Body.Close()
fmt.Printf("res: %+v\n", res)
_, err = io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
}
// fmt.Printf("body: %v\n", string(body))

time.Sleep(3 * time.Second)
}
}
}
3 changes: 2 additions & 1 deletion additions/outbound-tls-openssl/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash

docker build . -t mertyildiran/mizutest-outbound-tls-openssl:latest && docker push mertyildiran/mizutest-outbound-tls-openssl:latest
# docker build . -t mertyildiran/mizutest-outbound-tls-openssl:latest && docker push mertyildiran/mizutest-outbound-tls-openssl:latest
docker buildx build --platform linux/amd64 -t alongir/mizutest-outbound-tls-openssl:latest . --push
18 changes: 10 additions & 8 deletions additions/outbound-tls-openssl/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
j += 1
# print("-----\n%d" % j)

# First request - POST
url = "https://gorest.co.in/public/v2/users"

payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\njohn.doe.%d@example.com\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nJohn\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"gender\"\r\n\r\nmale\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"status\"\r\n\r\nactive\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--" % j
headers = {
'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
Expand All @@ -22,36 +22,38 @@

try:
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
response.close()
except Exception as e:
logging.error(traceback.format_exc())

# print(response.text)

# Second request - GET
url = "https://gorest.co.in/public/v2/users"

headers = {
'cache-control': "no-cache",
'x-powered-by': "openssl",
}

try:
response = requests.request("GET", url, headers=headers)
print(response.text)
response.close()
except Exception as e:
logging.error(traceback.format_exc())

# print(response.text)

# Third request - GET
url = "https://gorest.co.in/public/v2/posts"

headers = {
'cache-control': "no-cache",
'x-powered-by': "openssl",
}

try:
response = requests.request("GET", url, headers=headers)
print(response.text)
response.close()
except Exception as e:
logging.error(traceback.format_exc())

# print(response.text)
# Wait for 3 seconds before the next iteration
time.sleep(3)
Binary file added deploy/kubernetes/kubeshark
Binary file not shown.
Binary file added deploy/kubernetes/terraform/input.txt
Binary file not shown.
3 changes: 3 additions & 0 deletions deploy/kubernetes/terraform/varfile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"env_name": "dko-7"
}
8 changes: 4 additions & 4 deletions deploy/kubernetes/tls-demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
spec:
containers:
- name: mizutest-outbound-tls-openssl
image: mertyildiran/mizutest-outbound-tls-openssl:latest
image: alongir/mizutest-outbound-tls-openssl:latest
env:
- name: PYTHONUNBUFFERED
value: "1"
Expand All @@ -50,7 +50,7 @@ spec:
# - NET_BIND_SERVICE
# readOnlyRootFilesystem: true
nodeSelector:
beta.kubernetes.io/os: linux
kubernetes.io/os: linux
---
apiVersion: v1
kind: Service
Expand Down Expand Up @@ -88,7 +88,7 @@ spec:
spec:
containers:
- name: mizutest-outbound-tls-golang
image: mertyildiran/mizutest-outbound-tls-golang:latest
image: alongir/mizutest-outbound-tls-golang:latest
imagePullPolicy: Always
command: ["./main"]
resources:
Expand All @@ -110,7 +110,7 @@ spec:
# - NET_BIND_SERVICE
# readOnlyRootFilesystem: true
nodeSelector:
beta.kubernetes.io/os: linux
kubernetes.io/os: linux
---
apiVersion: v1
kind: Service
Expand Down

0 comments on commit c0c6c7a

Please sign in to comment.