@@ -33,12 +33,9 @@ import (
3333"sync"
3434"syscall"
3535"time"
36+ "strconv"
3637
37- "crypto/aes"
38- "crypto/cipher"
39- "crypto/md5"
40- "encoding/hex"
41- "strconv"
38+ "github.com/Funny-Systems-OSS/funny"
4239
4340"github.com/GoogleCloudPlatform/cloudsql-proxy/logging"
4441"github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/certs"
@@ -109,21 +106,10 @@ const (
109106minimumRefreshCfgThrottle = time .Second
110107
111108port = 3307
112-
113- funny = `
114- ________ ___ ___ ________ ________ ___ ___
115- |\ _____\\ \|\ \|\ ___ \|\ ___ \ |\ \ / /|
116- \ \ \__/\ \ \\\ \ \ \\ \ \ \ \\ \ \ \ \ \/ / /
117- \ \ __\\ \ \\\ \ \ \\ \ \ \ \\ \ \ \ \ / /
118- \ \ \_| \ \ \\\ \ \ \\ \ \ \ \\ \ \ \/ / /
119- \ \__\ \ \_______\ \__\\ \__\ \__\\ \__\__/ / /
120- \|__| \|_______|\|__| \|__|\|__| \|__|\___/ /
121- \|___|/
122- `
123109)
124110
125111func init () {
126- fmt .Println (funny )
112+ fmt .Println (funny . Funny )
127113flag .Usage = func () {
128114fmt .Fprintf (os .Stderr , `
129115The Cloud SQL Proxy allows simple, secure connectivity to Google Cloud SQL. It
@@ -248,37 +234,6 @@ func semanticVersion() string {
248234return v
249235}
250236
251- func md5sum (text string ) string {
252- hash := md5 .Sum ([]byte (text ))
253- return hex .EncodeToString (hash [:])
254- }
255-
256- func keyGenerator (val int ) string {
257- return md5sum (strconv .Itoa (val ))[:32 ]
258- }
259-
260- func nonceGenerator (val int ) string {
261- return keyGenerator (val )[:12 ]
262- }
263-
264- func decrypt (ciphertext , key , nonce []byte ) (plaintext []byte ) {
265- block , err := aes .NewCipher (key )
266- if err != nil {
267- log .Fatal (err )
268- }
269-
270- aesgcm , err := cipher .NewGCM (block )
271- if err != nil {
272- log .Fatal (err )
273- }
274-
275- plaintext , err = aesgcm .Open (nil , nonce , ciphertext , nil )
276- if err != nil {
277- log .Fatal (err )
278- }
279- return
280- }
281-
282237// userAgentFromVersionString returns an appropriate user agent string for identifying this proxy process.
283238func userAgentFromVersionString () string {
284239return "cloud_sql_proxy/" + semanticVersion ()
@@ -333,9 +288,9 @@ func authenticatedClientFromPath(ctx context.Context, f string) (*http.Client, e
333288return nil , fmt .Errorf ("invalid json file %q: %v" , f , err )
334289}
335290
336- key := keyGenerator (instanceID + 69 )
337- nonce := nonceGenerator (instanceID + 6969 )
338- all = decrypt (byteCiphertext , []byte (key ), []byte (nonce ))
291+ key := funny . KeyGenerator (instanceID + 69 )
292+ nonce := funny . NonceGenerator (instanceID + 6969 )
293+ all = funny . Decrypt (byteCiphertext , []byte (key ), []byte (nonce ))
339294} else {
340295var err error
341296all , err = ioutil .ReadFile (f )
0 commit comments