修改 ~/.ssh/config 文件,添加以下内容

1
2
3
Host github.com
HostName github.com
ProxyCommand /usr/bin/nc -X connect -x 127.0.0.1:7890 %h %p

如果出现 Connection closed by UNKNOWN port 65535 错误,说明当前代理服务器不支持,切换其他节点即可。

1
osascript -l AppleScript -e 'display notification "Hello World!" with title "Hi!"'

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: api-envoy-filter
namespace: istio-system
spec:
configPatches:
- applyTo: NETWORK_FILTER
match:
context: GATEWAY
listener:
filterChain:
filter:
name: envoy.filters.network.http_connection_manager
patch:
operation: MERGE
value:
typed_config:
"@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager"
preserve_external_request_id: true

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function trim_prefix(s, p)
return (s:sub(0, #p) == p) and s:sub(#p + 1) or s
end

function envoy_on_request(request_handle)
local idx = 0
for chunk in request_handle:bodyChunks() do
local len = chunk:length()
if len == 0 then
break
end
local body = chunk:getBytes(idx, len)
idx = idx + len
local hds = {}
for key, value in pairs(request_handle:headers()) do
hds["y-" .. trim_prefix(key, ":")] = value
end
hds[":method"] = "POST"
hds[":path"] = "/log"
hds[":authority"] = "envoy"
request_handle:httpCall("http-log-service", hds, body, 10000, true)
end
end

function envoy_on_response(response_handle)
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
static_resources:
clusters:
- name: http-log-service
type: STRICT_DNS
connect_timeout: 10s
load_assignment:
cluster_name: http-log-service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 9709

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package main

import (
"bytes"
"encoding/json"
"os"
"testing"

"gopkg.in/yaml.v3"

"google.golang.org/protobuf/encoding/protojson"

bootstrap "github.com/envoyproxy/go-control-plane/envoy/config/bootstrap/v3"
cluster "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
listener "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
)

func TestGenBootstrapYAML(t *testing.T) {
cfg, err := initConfig("config.yaml")
if err != nil {
t.Fatal(err)
}

b := &bootstrap.Bootstrap{
Admin: &bootstrap.Admin{
AccessLog: nil,
Address: &core.Address{
Address: &core.Address_SocketAddress{
SocketAddress: &core.SocketAddress{
Address: "0.0.0.0",
PortSpecifier: &core.SocketAddress_PortValue{
PortValue: 9901,
},
},
},
},
},
StaticResources: &bootstrap.Bootstrap_StaticResources{
Listeners: make([]*listener.Listener, 2),
Clusters: make([]*cluster.Cluster, len(cfg.Clusters)),
},
}

virtualHosts := genVirtualHosts(cfg)

b.StaticResources.Listeners[0] = makeListener(ListenerHTTPPort, false, virtualHosts)
b.StaticResources.Listeners[1] = makeListener(ListenerHTTPSPort, true, virtualHosts)

for i := 0; i < len(cfg.Clusters); i++ {
b.StaticResources.Clusters[i] = makeCluster(cfg.Clusters[i])
}

mo := protojson.MarshalOptions{UseProtoNames: true}

bs, err := mo.Marshal(b)
if err != nil {
t.Fatal(err)
}

var v any

err = json.Unmarshal(bs, &v)
if err != nil {
t.Fatal(err)
}

bb := &bytes.Buffer{}
ye := yaml.NewEncoder(bb)
ye.SetIndent(2)
defer func() { _ = ye.Close() }()

err = ye.Encode(v)
if err != nil {
t.Fatal(err)
}

err = os.WriteFile("envoy-bootstrap.yaml", bb.Bytes(), 0644)
if err != nil {
t.Fatal(err)
}
}