From a8dd10f44f961cea2d97c2033fee7ecd6fd78aff Mon Sep 17 00:00:00 2001 From: yzp0n Date: Mon, 4 May 2020 00:07:16 +0900 Subject: [PATCH] film demo --- docs/demo.svg | 367 +++++++++++++++++++++++++++++++++++++++ storage/storage.go | 2 +- tools/demoenv/bashrc | 14 ++ tools/demoenv/demoenv.sh | 5 + tools/demoenv/sh_wrap.sh | 2 + 5 files changed, 389 insertions(+), 1 deletion(-) create mode 100644 docs/demo.svg create mode 100755 tools/demoenv/bashrc create mode 100755 tools/demoenv/demoenv.sh create mode 100755 tools/demoenv/sh_wrap.sh diff --git a/docs/demo.svg b/docs/demo.svg new file mode 100644 index 0000000..81fcbef --- /dev/null +++ b/docs/demo.svg @@ -0,0 +1,367 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + $ $ k $ km $ kmg $ kmgm $ kmgm $ kmgm s $ kmgm se $ kmgm set $ kmgm setu $ kmgm setup $ kmgm setup INFOStarting CA setup for Profile{"/tmp/kmgmdemo/.config/kmgm/default"}. --- # kmgm PKI CA config setup: # The subject explains name, affiliation, and location of the target computer, # user, or service the cert is issued against.subject:commonName: lynx CAorganization:organizationalUnit:country: JPlocality:province: TokyostreetAddress:postalCode: # validity specifies the lifetime the ca is valid for.validity: farfuture # validity: 30d # valid for 30 days from now. # validity: 2y # valid for 2 years from now. # validity: 20220530 # valid until yyyyMMdd. # validity: farfuture # valid effectively foreverkeyType: rsa~ ~/.kmgm_input.yaml [yaml][utf-8][unix] 1 1/24:--- : :w :wq :wq"~/.kmgm_input.yaml"24L, 620C written "~/.kmgm_input.yaml"24L, 620C written Validator passed :) INFOGenerating key...{"usage": "CA", "type": "rsa"}INFOGenerating key... Done.{"usage": "CA", "type": "rsa", "took": 1.105760816}INFOThe CA private key saved to file: /tmp/kmgmdemo/.config/kmgm/default/cakey.pemINFOGenerating certificate...INFOGenerating certificate... Done.{"took": 0.006684672}INFOThe CA certificate saved to file: /tmp/kmgmdemo/.config/kmgm/default/cacert.pemINFOCA setup successfully completed for Profile{"/tmp/kmgmdemo/.config/kmgm/default"}$ kmgm i $ kmgm is $ kmgm iss $ kmgm issu $ kmgm issue $ kmgm issueINFOProfile{"/tmp/kmgmdemo/.config/kmgm/default"} already has a CA setup. Private key file: /tmp/kmgmdemo/key.pem Private key file: /tmp/kmgmdemo/key.pem Certificate pem file: /tmp/kmgmdemo/cert.pem Certificate pem file: /tmp/kmgmdemo/cert.pem --- # kmgm pki new cert configprivateKeyPath: /tmp/kmgmdemo/key.pemcertPath: /tmp/kmgmdemo/cert.pem issue: # The subject explains name, affiliation, and location of the target computer, subject: commonName: lynx organizationalUnit: country: JP locality: province: Tokyo streetAddress: postalCode: # The subjectAltNames specifies hostnames or ipaddrs which the cert is issued # against. subjectAltNames --- subjectAltNames: - demohost - demohost.example - 192.168.0.10 # validity specifies the lifetime the cert is valid for. validity: 820d ~/.kmgm_input.yaml [yaml][utf-8][unix] 1 1/54 gj # kmgm pki new cert config~/.kmgm_input.yaml [yaml][utf-8][unix] 1 2/54 ~/.kmgm_input.yaml [yaml][utf-8][unix] 1 3/54privateKeyPath: /tmp/kmgmdemo/key.pem~/.kmgm_input.yaml [yaml][utf-8][unix] 1 4/54certPath: /tmp/kmgmdemo/cert.pem ~/.kmgm_input.yaml [yaml][utf-8][unix] 1 5/54issue: ~/.kmgm_input.yaml [yaml][utf-8][unix] 1 6/54# The subject explains name, affiliation, and location of the target computer,~/.kmgm_input.yaml [yaml][utf-8][unix] 1 7/54 # user, or service the cert is issued against.~/.kmgm_input.yaml [yaml][utf-8][unix] 1 8/54 subject: ~/.kmgm_input.yaml [yaml][utf-8][unix] 1 9/54 commonName: lynx ~/.kmgm_input.yaml [yaml][utf-8][unix] 1 10/54 organization:~/.kmgm_input.yaml [yaml][utf-8][unix] 1 11/54 gk f fl commonName: lynx ~/.kmgm_input.yaml [yaml][utf-8][unix] 17 10/54 c cw commonName: ~/.kmgm_input.yaml [+][yaml][utf-8][unix] 17 10/54-- INSERT -- commonName: n ~/.kmgm_input.yaml [+][yaml][utf-8][unix] 18 10/54 commonName: ng ~/.kmgm_input.yaml [+][yaml][utf-8][unix] 19 10/54 commonName: ng organizatio ng [A] commonName: ngi organization: commonName: ngi ~/.kmgm_input.yaml [+][yaml][utf-8][unix] 20 10/54 commonName: ngin ~/.kmgm_input.yaml [+][yaml][utf-8][unix] 21 10/54 commonName: nginx ~/.kmgm_input.yaml [+][yaml][utf-8][unix] 22 10/54 commonName: nginx commonName: nginx : : :w :wq :wq "~/.kmgm_input.yaml" 54L, 1375C written "~/.kmgm_input.yaml" 54L, 1375C written Validator passed :) INFOGenerating key...{"usage": "", "type": "rsa"}INFOGenerating key... Done.{"usage": "", "type": "rsa", "took": 1.25027682}INFOAllocated sn: 2568400342232091647INFOGenerating certificate... Done.{"took": 0.00680928}$ o $ op $ ope $ open $ opens $ openss $ openssl $ openssl $ openssl x $ openssl x5 $ openssl x50 $ openssl x509 $ openssl x509 $ openssl x509 - $ openssl x509 -i $ openssl x509 -in $ openssl x509 -in $ openssl x509 -in c $ openssl x509 -in ce $ openssl x509 -in cer $ openssl x509 -in cert $ openssl x509 -in cert. $ openssl x509 -in cert.p $ openssl x509 -in cert.pe $ openssl x509 -in cert.pem $ openssl x509 -in cert.pem $ openssl x509 -in cert.pem - $ openssl x509 -in cert.pem -t $ openssl x509 -in cert.pem -te $ openssl x509 -in cert.pem -tex $ openssl x509 -in cert.pem -text $ openssl x509 -in cert.pem -text $ openssl x509 -in cert.pem -text - $ openssl x509 -in cert.pem -text -n $ openssl x509 -in cert.pem -text -no $ openssl x509 -in cert.pem -text -noo $ openssl x509 -in cert.pem -text -noou $ openssl x509 -in cert.pem -text -noout $ openssl x509 -in cert.pem -text -noout $ openssl x509 -in cert.pem -text -noout | $ openssl x509 -in cert.pem -text -noout | $ openssl x509 -in cert.pem -text -noout | h $ openssl x509 -in cert.pem -text -noout | he $ openssl x509 -in cert.pem -text -noout | hea $ openssl x509 -in cert.pem -text -noout | head $ openssl x509 -in cert.pem -text -noout | head $ openssl x509 -in cert.pem -text -noout | head - $ openssl x509 -in cert.pem -text -noout | head -n $ openssl x509 -in cert.pem -text -noout | head -n $ openssl x509 -in cert.pem -text -noout | head -n 2 $ openssl x509 -in cert.pem -text -noout | head -n 20 $ openssl x509 -in cert.pem -text -noout | head -n 20Certificate: Data: Version: 3 (0x2) Serial Number: 2568400342232091647 (0x23a4ca80d7bc4bff) Signature Algorithm: sha256WithRSAEncryption Issuer: C = JP, ST = Tokyo, CN = lynx CA Validity Not Before: May 3 15:04:00 2020 GMT Not After : Aug 1 15:05:00 2022 GMT Subject: C = JP, ST = Tokyo, CN = nginx Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public-Key: (4096 bit) Modulus: 00:b9:35:91:ad:dd:19:36:ae:42:a3:1d:b2:d2:85: f8:ec:17:ca:29:2c:73:5c:fb:c2:23:86:29:6a:ed: 3e:92:ea:ce:9f:ee:ba:81:7d:56:5a:98:5f:23:9c: 68:0d:ec:43:9b:4c:88:93:e2:2c:7a:d8:77:5f:1b: f3:d0:16:cd:70:28:b1:e1:98:d1:80:f2:da:8c:e4: 55:85:ba:1d:e8:b7:9b:ad:15:e2:80:e6:32:69:27:$ exit + 0:00/0:00 + + + + + + + + + + \ No newline at end of file diff --git a/storage/storage.go b/storage/storage.go index a2a8155..13d2cf6 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -48,7 +48,7 @@ func (s *Storage) mkdirIfNeeded() error { func (s *Storage) GeoIpCachePath() string { _ = s.mkdirIfNeeded() - return filepath.Join(s.BaseDir, "geoip_cache.yaml") + return filepath.Join(s.BaseDir, "geoip_cache.json") } type Profile struct { diff --git a/tools/demoenv/bashrc b/tools/demoenv/bashrc new file mode 100755 index 0000000..52e4c84 --- /dev/null +++ b/tools/demoenv/bashrc @@ -0,0 +1,14 @@ +export LANG=en_US.UTF-8 +export HOSTNAME=demohost + +PS1="$ " + +export PATH="$(pwd)/../..:$PATH" + +rm -rf /tmp/kmgmdemo +export KMGMDIR=/tmp/kmgmdemo/.config/kmgm +mkdir -p $KMGMDIR +echo '{"city":"Bunkyo","country":"Japan","countryCode":"JP","regionName":"Tokyo","timezone":"Asia/Tokyo"}' > $KMGMDIR/geoip_cache.json + +export KMGM_DEFAULT_NAMES="demohost,demohost.example,192.168.0.10" +cd /tmp/kmgmdemo diff --git a/tools/demoenv/demoenv.sh b/tools/demoenv/demoenv.sh new file mode 100755 index 0000000..b82fdd3 --- /dev/null +++ b/tools/demoenv/demoenv.sh @@ -0,0 +1,5 @@ +#!/bin/bash +cd $(dirname $0) +mkdir -p /tmp/kmgmdemo/.config/kmgm + +termtosvg -t window_frame_js -g 120x30 -c ./sh_wrap.sh diff --git a/tools/demoenv/sh_wrap.sh b/tools/demoenv/sh_wrap.sh new file mode 100755 index 0000000..c4e18d1 --- /dev/null +++ b/tools/demoenv/sh_wrap.sh @@ -0,0 +1,2 @@ +#!/bin/sh +exec bash --rcfile bashrc