[컴][네트워크] reverse proxy

리버스 프록시 / 프록시 간단/ 프록시란

reverse proxy

reverse proxy 의 의미를 보면 forward proxy 와 ’역’방향이라는 이야기다.

forward proxy <--> reverse proxy

아래 그림을 보면서 이해해 보자.

여기서 중요한 것은 방향이다. client 에서 출발해서 server 방향으로 간다. 이 방향을 기본으로 해서, forward proxy 가 정방향이 되는 것이고, reverse proxy 가 역방향이 되는 것이다.

reverse proxy 는 load balancer를 생각해보면 쉽다. reverse proxy 가 client 들로 부터 오는 packet 을 받아서 어느 서버로 전달할 지를 정해서 보내준다.

proxy 는 ’대리자’이다. 가장 우리가 많이 사용하는 경우가 internet proxy 이다. 특정 상황에서 internet 이 막혀있다면, 이 proxy 를 통해서 인터넷에 접근할 수 있다. 그런데 이런방식은 결국 모든 나가는 packet을 proxy 를 통해서 나가게 만든다. 즉, proxy 가 일종의 gate 같은 역할을 하게 된다.

이것에 대한 기술적 구현은 다양할 수 있다. 구체적으로 지원하는 기능도 다를 수 있다. 그저 개념적으로 어디에 위치해서 어떤 역할을 하느냐가 forward / reverse proxy 를 결정한다고 보면 된다.

[컴] vue3 용 datepicker library

 

datepicker / date /

vue3 용 datepicker library

[컴][머신러닝] stable diffussion Web UI

스테이블 디퓨젼 , 디퓨전 / 사용 / hw spec

stable diffussion Web UI

하드웨어 스펙

  • i5-9400F, 2.90GHz
  • 8GB x 2
  • Geforce GTX 1660, 8GB

실행

  1. python 3.10.6 설치
  2. git 설치
  3. v1.0.0-pre 를 download(sd.webui.zip)
  4. python path 추가: set PATH=d:\apps\Python\Python311;d:\apps\Python\Python311\Scripts;%PATH%
  5. update.bat
  6. run.bat

실행화면

d:\a\prog\stablediffusion\webui>update.bat
Updating 48a15821..baf6946e
Fast-forward
 .eslintignore                                      |    4 +
 .eslintrc.js                                       |   88 ++
 .git-blame-ignore-revs                             |    2 +
 .github/ISSUE_TEMPLATE/bug_report.yml              |   50 +-
 .github/pull_request_template.md                   |   33 +-
 .github/workflows/on_pull_request.yaml             |   49 +-
 .github/workflows/run_tests.yaml                   |   53 +-
 .gitignore                                         |    6 +-
 CHANGELOG.md                                       |  200 +++
 README.md                                          |   39 +-
 configs/instruct-pix2pix.yaml                      |   98 ++
 .../v1-inpainting-inference.yaml                   |   36 +-
 environment-wsl2.yaml                              |   10 +-
 extensions-builtin/LDSR/ldsr_model_arch.py         |   13 +-
 extensions-builtin/LDSR/scripts/ldsr_model.py      |   23 +-
 extensions-builtin/LDSR/sd_hijack_autoencoder.py   |   28 +-
 extensions-builtin/LDSR/sd_hijack_ddpm_v1.py       |   66 +-
 extensions-builtin/Lora/extra_networks_lora.py     |   27 +-
 extensions-builtin/Lora/lora.py                    |  392 +++++-
 extensions-builtin/Lora/scripts/lora_script.py     |   90 +-
 extensions-builtin/Lora/ui_extra_networks_lora.py  |   16 +-
 extensions-builtin/ScuNET/scripts/scunet_model.py  |   98 +-
 extensions-builtin/ScuNET/scunet_model_arch.py     |   11 +-
 extensions-builtin/SwinIR/scripts/swinir_model.py  |    9 +-
 extensions-builtin/SwinIR/swinir_model_arch.py     |    6 +-
 extensions-builtin/SwinIR/swinir_model_arch_v2.py  |   58 +-
 .../javascript/prompt-bracket-checker.js           |  130 +-
 html/extra-networks-card.html                      |    7 +-
 html/licenses.html                                 |  271 ++++
 javascript/aspectRatioOverlay.js                   |  226 +--
 javascript/contextMenus.js                         |  349 +++--
 javascript/dragdrop.js                             |   52 +-
 javascript/edit-attention.js                       |  216 +--
 javascript/extensions.js                           |  109 +-
 javascript/extraNetworks.js                        |  284 +++-
 javascript/generationParams.js                     |   48 +-
 javascript/hints.js                                |  122 +-
 javascript/hires_fix.js                            |   40 +-
 javascript/imageMaskFix.js                         |   26 +-
 javascript/imageParams.js                          |    5 +-
 javascript/imageviewer.js                          |  283 ++--
 javascript/imageviewerGamepad.js                   |   57 +
 javascript/localization.js                         |  341 ++---
 javascript/notification.js                         |   20 +-
 javascript/progressbar.js                          |  250 ++--
 javascript/textualInversion.js                     |   34 +-
 javascript/ui.js                                   |  497 ++++---
 javascript/ui_settings_hints.js                    |   62 +
 launch.py                                          |  339 +----
 models/karlo/ViT-L-14_stats.th                     |  Bin 0 -> 7079 bytes
 modules/Roboto-Regular.ttf                         |  Bin 0 -> 305608 bytes
 modules/api/api.py                                 |  373 +++--
 modules/api/models.py                              |   54 +-
 modules/call_queue.py                              |    6 +-
 modules/cmd_args.py                                |  109 ++
 modules/codeformer/codeformer_arch.py              |   24 +-
 modules/codeformer/vqgan_arch.py                   |   44 +-
 modules/codeformer_model.py                        |   10 +-
 modules/config_states.py                           |  202 +++
 modules/deepbooru.py                               |    3 +-
 modules/deepbooru_model.py                         |    4 +-
 modules/devices.py                                 |  114 +-
 modules/esrgan_model.py                            |   21 +-
 modules/esrgan_model_arch.py                       |   24 +-
 modules/extensions.py                              |   89 +-
 modules/extra_networks.py                          |   16 +-
 modules/extra_networks_hypernet.py                 |    9 +-
 modules/extras.py                                  |   73 +-
 modules/generation_parameters_copypaste.py         |  285 ++--
 modules/gfpgan_model.py                            |    7 +-
 modules/hashes.py                                  |   41 +-
 modules/hypernetworks/hypernetwork.py              |   49 +-
 modules/hypernetworks/ui.py                        |    6 +-
 modules/images.py                                  |  193 ++-
 modules/img2img.py                                 |   54 +-
 modules/interrogate.py                             |   17 +-
 modules/launch_utils.py                            |  334 +++++
 modules/localization.py                            |    4 +-
 modules/lowvram.py                                 |   10 +-
 modules/mac_specific.py                            |   63 +
 modules/masking.py                                 |    2 +-
 modules/memmon.py                                  |   12 +-
 modules/modelloader.py                             |   78 +-
 modules/models/diffusion/ddpm_edit.py              | 1455 ++++++++++++++++++++
 modules/models/diffusion/uni_pc/__init__.py        |    1 +
 modules/models/diffusion/uni_pc/sampler.py         |  101 ++
 modules/models/diffusion/uni_pc/uni_pc.py          |  863 ++++++++++++
 modules/ngrok.py                                   |   30 +-
 modules/paths.py                                   |   11 +-
 modules/paths_internal.py                          |   31 +
 modules/postprocessing.py                          |    9 +-
 modules/processing.py                              |  414 ++++--
 modules/progress.py                                |   34 +-
 modules/prompt_parser.py                           |   27 +-
 modules/realesrgan_model.py                        |   26 +-
 modules/safe.py                                    |   17 +-
 modules/script_callbacks.py                        |  114 +-
 modules/script_loading.py                          |   11 +-
 modules/scripts.py                                 |  171 ++-
 modules/scripts_auto_postprocessing.py             |   42 +
 modules/scripts_postprocessing.py                  |   21 +-
 modules/sd_disable_initialization.py               |   19 +-
 modules/sd_hijack.py                               |  153 +-
 modules/sd_hijack_clip.py                          |    2 +-
 modules/sd_hijack_clip_old.py                      |    3 +-
 modules/sd_hijack_inpainting.py                    |   20 +-
 modules/sd_hijack_ip2p.py                          |   10 +
 modules/sd_hijack_optimizations.py                 |  347 ++++-
 modules/sd_hijack_unet.py                          |   51 +-
 modules/sd_hijack_utils.py                         |   28 +
 modules/sd_hijack_xlmr.py                          |    2 -
 modules/sd_models.py                               |  395 ++++--
 modules/sd_models_config.py                        |  118 ++
 modules/sd_samplers.py                             |  527 +------
 modules/sd_samplers_common.py                      |   95 ++
 modules/sd_samplers_compvis.py                     |  224 +++
 modules/sd_samplers_kdiffusion.py                  |  392 ++++++
 modules/sd_vae.py                                  |   16 +-
 modules/sd_vae_approx.py                           |    5 +-
 modules/sd_vae_taesd.py                            |   88 ++
 modules/shared.py                                  |  478 ++++---
 modules/shared_items.py                            |   31 +
 modules/styles.py                                  |   23 +-
 modules/sub_quadratic_attention.py                 |   21 +-
 modules/textual_inversion/autocrop.py              |  214 +--
 modules/textual_inversion/dataset.py               |   62 +-
 modules/textual_inversion/image_embedding.py       |   28 +-
 modules/textual_inversion/learn_schedule.py        |    6 +-
 modules/textual_inversion/preprocess.py            |   31 +-
 modules/textual_inversion/textual_inversion.py     |   78 +-
 modules/timer.py                                   |   38 +
 modules/txt2img.py                                 |   19 +-
 modules/ui.py                                      |  605 +++++---
 modules/ui_common.py                               |   27 +-
 modules/ui_components.py                           |   52 +-
 modules/ui_extensions.py                           |  384 +++++-
 modules/ui_extra_networks.py                       |  244 +++-
 modules/ui_extra_networks_checkpoints.py           |   31 +
 modules/ui_extra_networks_hypernets.py             |   13 +-
 modules/ui_extra_networks_textual_inversion.py     |   14 +-
 modules/ui_loadsave.py                             |  210 +++
 modules/ui_postprocessing.py                       |   10 +-
 modules/ui_tempdir.py                              |   19 +-
 modules/upscaler.py                                |   14 +-
 modules/xlmr.py                                    |    8 +-
 package.json                                       |   11 +
 pyproject.toml                                     |   35 +
 requirements-test.txt                              |    3 +
 requirements.txt                                   |   10 +-
 requirements_versions.txt                          |   24 +-
 script.js                                          |   94 +-
 scripts/custom_code.py                             |   65 +-
 scripts/img2imgalt.py                              |   48 +-
 scripts/loopback.py                                |  100 +-
 scripts/outpainting_mk_2.py                        |    8 +-
 scripts/poor_mans_outpainting.py                   |    8 +-
 scripts/postprocessing_upscale.py                  |   73 +-
 scripts/prompt_matrix.py                           |   52 +-
 scripts/prompts_from_file.py                       |   20 +-
 scripts/sd_upscale.py                              |   10 +-
 scripts/xy_grid.py                                 |  498 -------
 scripts/xyz_grid.py                                |  720 ++++++++++
 style.css                                          |  920 ++++++-------
 test/basic_features/__init__.py                    |    0
 test/basic_features/extras_test.py                 |   54 -
 test/basic_features/img2img_test.py                |   66 -
 test/basic_features/txt2img_test.py                |   80 --
 test/basic_features/utils_test.py                  |   62 -
 test/conftest.py                                   |   17 +
 test/server_poll.py                                |   24 -
 test/test_extras.py                                |   35 +
 test/test_img2img.py                               |   68 +
 test/test_txt2img.py                               |   90 ++
 test/test_utils.py                                 |   33 +
 webui-macos-env.sh                                 |    4 +-
 webui-user.sh                                      |    3 +
 webui.py                                           |  415 ++++--
 webui.sh                                           |   68 +-
 178 files changed, 14062 insertions(+), 5792 deletions(-)
 create mode 100644 .eslintignore
 create mode 100644 .eslintrc.js
 create mode 100644 .git-blame-ignore-revs
 create mode 100644 CHANGELOG.md
 create mode 100644 configs/instruct-pix2pix.yaml
 rename v2-inference-v.yaml => configs/v1-inpainting-inference.yaml (61%)
 create mode 100644 javascript/imageviewerGamepad.js
 create mode 100644 javascript/ui_settings_hints.js
 create mode 100644 models/karlo/ViT-L-14_stats.th
 create mode 100644 modules/Roboto-Regular.ttf
 create mode 100644 modules/cmd_args.py
 create mode 100644 modules/config_states.py
 create mode 100644 modules/launch_utils.py
 create mode 100644 modules/mac_specific.py
 create mode 100644 modules/models/diffusion/ddpm_edit.py
 create mode 100644 modules/models/diffusion/uni_pc/__init__.py
 create mode 100644 modules/models/diffusion/uni_pc/sampler.py
 create mode 100644 modules/models/diffusion/uni_pc/uni_pc.py
 create mode 100644 modules/paths_internal.py
 create mode 100644 modules/scripts_auto_postprocessing.py
 create mode 100644 modules/sd_hijack_ip2p.py
 create mode 100644 modules/sd_hijack_utils.py
 create mode 100644 modules/sd_models_config.py
 create mode 100644 modules/sd_samplers_common.py
 create mode 100644 modules/sd_samplers_compvis.py
 create mode 100644 modules/sd_samplers_kdiffusion.py
 create mode 100644 modules/sd_vae_taesd.py
 create mode 100644 modules/shared_items.py
 create mode 100644 modules/timer.py
 create mode 100644 modules/ui_extra_networks_checkpoints.py
 create mode 100644 modules/ui_loadsave.py
 create mode 100644 package.json
 create mode 100644 pyproject.toml
 create mode 100644 requirements-test.txt
 delete mode 100644 scripts/xy_grid.py
 create mode 100644 scripts/xyz_grid.py
 delete mode 100644 test/basic_features/__init__.py
 delete mode 100644 test/basic_features/extras_test.py
 delete mode 100644 test/basic_features/img2img_test.py
 delete mode 100644 test/basic_features/txt2img_test.py
 delete mode 100644 test/basic_features/utils_test.py
 create mode 100644 test/conftest.py
 delete mode 100644 test/server_poll.py
 create mode 100644 test/test_extras.py
 create mode 100644 test/test_img2img.py
 create mode 100644 test/test_txt2img.py
 create mode 100644 test/test_utils.py
계속하려면 아무 키나 누르십시오 . . .

d:\a\prog\stablediffusion\webui>run.bat
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.3.2
Commit hash: baf6946e06249c5af9851c60171692c44ef633e0
Installing torch and torchvision
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu118
Collecting torch==2.0.1
  Downloading https://download.pytorch.org/whl/cu118/torch-2.0.1%2Bcu118-cp310-cp310-win_amd64.whl (2619.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.6/2.6 GB 2.2 MB/s eta 0:00:00
Collecting torchvision==0.15.2
  Downloading https://download.pytorch.org/whl/cu118/torchvision-0.15.2%2Bcu118-cp310-cp310-win_amd64.whl (4.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.9/4.9 MB 22.5 MB/s eta 0:00:00
Collecting filelock (from torch==2.0.1)
  Downloading filelock-3.12.2-py3-none-any.whl (10 kB)
Collecting typing-extensions (from torch==2.0.1)
  Downloading typing_extensions-4.6.3-py3-none-any.whl (31 kB)
Collecting sympy (from torch==2.0.1)
  Downloading sympy-1.12-py3-none-any.whl (5.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.7/5.7 MB 22.9 MB/s eta 0:00:00
Collecting networkx (from torch==2.0.1)
  Using cached networkx-3.1-py3-none-any.whl (2.1 MB)
Collecting jinja2 (from torch==2.0.1)
  Downloading https://download.pytorch.org/whl/Jinja2-3.1.2-py3-none-any.whl (133 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB ? eta 0:00:00
Collecting numpy (from torchvision==0.15.2)
  Downloading numpy-1.25.0-cp310-cp310-win_amd64.whl (15.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.0/15.0 MB 23.4 MB/s eta 0:00:00
Collecting requests (from torchvision==0.15.2)
  Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Collecting pillow!=8.3.*,>=5.3.0 (from torchvision==0.15.2)
  Using cached Pillow-9.5.0-cp310-cp310-win_amd64.whl (2.5 MB)
Collecting MarkupSafe>=2.0 (from jinja2->torch==2.0.1)
  Downloading MarkupSafe-2.1.3-cp310-cp310-win_amd64.whl (17 kB)
Collecting charset-normalizer<4,>=2 (from requests->torchvision==0.15.2)
  Using cached charset_normalizer-3.1.0-cp310-cp310-win_amd64.whl (97 kB)
Collecting idna<4,>=2.5 (from requests->torchvision==0.15.2)
  Using cached https://download.pytorch.org/whl/idna-3.4-py3-none-any.whl (61 kB)
Collecting urllib3<3,>=1.21.1 (from requests->torchvision==0.15.2)
  Using cached urllib3-2.0.3-py3-none-any.whl (123 kB)
Collecting certifi>=2017.4.17 (from requests->torchvision==0.15.2)
  Using cached certifi-2023.5.7-py3-none-any.whl (156 kB)
Collecting mpmath>=0.19 (from sympy->torch==2.0.1)
  Using cached mpmath-1.3.0-py3-none-any.whl (536 kB)
Installing collected packages: mpmath, urllib3, typing-extensions, sympy, pillow, numpy, networkx, MarkupSafe, idna, filelock, charset-normalizer, certifi, requests, jinja2, torch, torchvision
Successfully installed MarkupSafe-2.1.3 certifi-2023.5.7 charset-normalizer-3.1.0 filelock-3.12.2 idna-3.4 jinja2-3.1.2 mpmath-1.3.0 networkx-3.1 numpy-1.25.0 pillow-9.5.0 requests-2.31.0 sympy-1.12 torch-2.0.1+cu118 torchvision-0.15.2+cu118 typing-extensions-4.6.3 urllib3-2.0.3
Installing gfpgan
Installing clip
Installing open_clip
Cloning Stable Diffusion into D:\a\prog\stablediffusion\webui\webui\repositories\stable-diffusion-stability-ai...
Cloning Taming Transformers into D:\a\prog\stablediffusion\webui\webui\repositories\taming-transformers...
Cloning K-diffusion into D:\a\prog\stablediffusion\webui\webui\repositories\k-diffusion...
Cloning CodeFormer into D:\a\prog\stablediffusion\webui\webui\repositories\CodeFormer...
Cloning BLIP into D:\a\prog\stablediffusion\webui\webui\repositories\BLIP...
Installing requirements for CodeFormer
Installing requirements
Launching Web UI with arguments:
No module 'xformers'. Proceeding without it.
Downloading: "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors" to D:\a\prog\stablediffusion\webui\webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors

100%|███████████████████████████████████████████████████████████████████████████████| 3.97G/3.97G [03:02<00:00, 23.4MB/s]
Calculating sha256 for D:\a\prog\stablediffusion\webui\webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors: Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 190.6s (import torch: 1.8s, import gradio: 2.4s, import ldm: 0.5s, other imports: 1.9s, setup codeformer: 0.1s, list SD models: 182.4s, load scripts: 0.8s, create ui: 0.2s, gradio launch: 0.4s).
6ce0161689b3853acaa03779ec93eafe75a02f4ced659bee03f50797806fa2fa
Loading weights [6ce0161689] from D:\a\prog\stablediffusion\webui\webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors
Creating model from config: D:\a\prog\stablediffusion\webui\webui\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Downloading (…)olve/main/vocab.json: 100%|████████████████████████████████████████████| 961k/961k [00:00<00:00, 1.62MB/s]
Downloading (…)olve/main/merges.txt: 100%|█████████████████████████████████████████████| 525k/525k [00:00<00:00, 890kB/s]
Downloading (…)cial_tokens_map.json: 100%|██████████████████████████████████████████████████████| 389/389 [00:00<?, ?B/s]
Downloading (…)okenizer_config.json: 100%|██████████████████████████████████████████████████████| 905/905 [00:00<?, ?B/s]
Downloading (…)lve/main/config.json: 100%|██████████████████████████████████████████████████| 4.52k/4.52k [00:00<?, ?B/s]
Applying optimization: Doggettx... done.
Textual inversion embeddings loaded(0):
Model loaded in 10.5s (calculate hash: 3.6s, load weights from disk: 0.1s, create model: 3.8s, apply weights to model: 0.6s, apply half(): 0.6s, move model to device: 0.9s, load textual inversion embeddings: 0.8s).
100%|████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:07<00:00,  2.81it/s]
Total progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:03<00:00,  6.61it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:03<00:00,  6.61it/s]
Total progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  7.03it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:03<00:00,  6.61it/s]
Total progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  7.05it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:05<00:00,  3.42it/s]
Total progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:05<00:00,  3.39it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  6.67it/s]
Total progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  6.69it/s]
Interrupted with signal 2 in <frame at 0x000001DD2E5D1170, file 'threading.py', line 324, code wait>██████████████████████| 20/20 [00:02<00:00,  7.08it/s]
일괄 작업을 끝내시겠습니까 (Y/N)? y

See Also

  1. How to use models · civitai/civitai Wiki · GitHub : <civitai.com> 에서 model을 받아서 local에서 사용해 볼 수 있다.

[컴][네트워크] android packet capture 방법

/ pc ap역할/ 패킷 캡쳐 / android windows capture

android packet capture 방법

  1. tPacketCapture - Apps on Google Play : 이 녀석은 좋다. 다만 최근 버전에서는 이 녀석을 사용할 수 없다. 왜냐하면 저장한 파일을 다른 곳으로 전송할 수가 없다. ’공유(share)’도 제대로 동작하지 않는다. 다만 ’블루투스’는 시도해보지 않았다.

                    xxx x x xxxx
                x xx           xx x
            xxxx                     x   x xxxxxxx
        xxxx                          xx         x
       xx                                        x
       x            internet                  xxx
        x                                    x x
        xxx xx xxx                              x
             xxx  xx                             x
                   xxxxxx x   xxxxx x   xxx   x xx
                        ▲             xx  xxx
                        │
               ┌────────┘
               │
        ┌──────┴───────┐          ┌───────────────────┐
        │              │          │                   │
        │  acess       │          │                   │
        │  point       │◄─────────┤   android phone   │
        │ (windows PC) │          │                   │
        │              │          └───────────────────┘
        └──────────────┘

  1. 컴퓨터를 안드로이드폰과 같은 네트워크(LAN) 에 둔다.
  2. wireless access point 역할을 하도록 한다.
    • windows10 에서는 settings –> Network & internet –> Mobile hotspot [ref. 2]
  3. wireshark 로 packet 을 잡는다.

fiddler 로 capture

이것은 web browser 의 packet 을 잡을 때 유용하다.

  1. fiddler classic download : https://www.telerik.com/download/fiddler/fiddler4
  2. extension CertMaker for iOS and Android’ 설치 : https://telerik-fiddler.s3.amazonaws.com/fiddler/addons/fiddlercertmaker.exe
  3. options –> https tab –> Capture HTTPS CONNECTs –> Decript HTTPS traffic (ignore server certificate errors 를 check 할 필요가 있을 수 있다.)
  4. options –> connections tab –> Allow remote computers to connect
  5. android phone 에서 현재 연결된 AP 설정화면에서 proxy setting(프록시) 를 수동(manual) 로 해서 proxy 를 추가한다.
    • fiddler 가 있는 pc의 ip address (여기서는 192.168.0.1 이라고 하자.)
    • fiddler 에 설정된 port 로 설정(여기서는 8888이라고 하자.)
  6. android phone 에서 web browser 로 http://192.168.0.1:8888 로 접속한다.
  7. Fiddler cert 를 download : 화면에 Fiddler cert 를 download 할 수 있는 link 가 있다.
  8. android 에서 ‘CA 인증서’ 설치로 위에서 다운로드한 cert 를 설치한다. –> 작업이 끝나면 삭제하자.
  9. 이제 원하는 site 에 접속하면, fiddler 에 request 내용 이 잡힌다.


                    xxx x x xxxx
                x xx           xx x
            xxxx                     x   x xxxxxxx
        xxxx                          xx         x
       xx                                        x
       x            internet                  xxx
        x                                    x x
        xxx xx xxx                              x
             xxx  xx                             x
                   xxxxxx x   xxxxx x   xxx   x xx
                        ▲             xx  xxx
                        │
               ┌────────┘
               │
        ┌──────┴───────┐          ┌───────────────────┐
        │              │          │                   │
        │  proxy       │          │                   │
        │  (fiddler)   │◄─────────┤   android phone   │
        │ (windows PC) │          │                   │
        │              │          └───────────────────┘
        └──────────────┘

fiddler classic 에서 Bouncy Castle certificate 을 사용하는 법[ref. 3]

  1. extension ‘CertMaker for iOS and Android’ 을 download : https://telerik-fiddler.s3.amazonaws.com/fiddler/addons/fiddlercertmaker.exe
    • 이 extension 을 설치하면 만기가 2년인 cert 가 만들어진다. 이 extension 을 설치하지 않으면 만기가 아주 긴 cert 가 만들어진다.
  2. ’실행’하면 설치가 완료된다.

설치된 인증서 삭제

windows 의 경우:

Reference

  1. android - Capturing mobile phone traffic on Wireshark - Stack Overflow
  2. Use your Windows PC as a mobile hotspot - Microsoft Support
  3. How to use Bouncy Castle certificates generator in Fiddler | Telerik Forums

[컴] boto3 로 presigned url 을 사용해서 aws s3 에 이미지 upload 하기

boto3 aws presigned url upload example / python aws client

boto3 로 presigned url 을 사용해서 aws s3 에 이미지 upload 하기

이 글은 windows 에서 작업한 내용이다.

환경설정

ref. 1 을 보고 환경을 설정하자.

설치

python -m venv .venv
.venv\Scripts\activate
python -m pip install boto3 pytest requests

실행

presigned_url.py 를 실행하면 된다. 아래는 ’test.png’를 upload 하는 command 이다.

python presigned_url.py mytestbucket test.png put

SignatureDoesNotMatch

위처럼 하면 SignatureDoesNotMatch 라는 error 가 발생했다. presinged_url.py 에서 다음 부분을 수정해 주면 된다.[ref. 3 참고]

s3_client = boto3.client('s3', region_name='ap-northeast-2', endpoint_url='https://s3.ap-northeast-2.amazonaws.com')

실행 화면:

(.venv) d:\python\aws>python presigned_url.py mytestbucket test.png put
----------------------------------------------------------------------------------------
Welcome to the Amazon S3 presigned URL demo.
----------------------------------------------------------------------------------------
INFO: Found credentials in shared credentials file: ~/.aws/credentials
INFO: Got presigned URL: https://s3.ap-northeast-2.amazonaws.com/mytestbucket/test.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MYMYMYMYMYMY%2F20230613%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20230613T011310Z&X-Amz-Expires=1000&X-Amz-SignedHeaders=host&X-Amz-Signature=17c57d34c54ada2e0bde2899f7c67cd2bf044db3f3f3f3f3f3f3f35
Using the Requests package to send a request to the URL.
Putting data to the URL.
Got response:
Status: 200

----------------------------------------------------------------------------------------

curl 로 upload

위에서 생성한 presigned url 을 이용해서 http request 로 upload 를 하면 된다. 그래서 curl 로도 upload 가 가능하다. 아래는 windows curl 의 예시다.

curl -v -X PUT --upload-file "test.png" "https://s3.ap-northeast-2.amazonaws.com/mytestbucket/test.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MYMYMYMYMYMY%2F20230613%2Fap-northeast-2%2Fs3%2Faws4_request&X-Amz-Date=20230613T011310Z&X-Amz-Expires=1000&X-Amz-SignedHeaders=host&X-Amz-Signature=17c57d34c54ada2e0bde2899f7c67cd2bf044db3f3f3f3f3f3f3f35"

See Also

  1. 쿠…sal: [컴][웹] AWS CLI 로 s3 에 파일 업로드 하기

Reference

  1. aws-doc-sdk-examples/README.md at main · awsdocs/aws-doc-sdk-examples · GitHub
  2. https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/python/example_code/s3/s3_basics/presigned_url.py
  3. boto3 lib of python, s3 image upload using presigned url with content type · Issue #1149 · boto/boto3 · GitHub

[컴] js 에서 타이핑중인 글자를 얻는 방법

 

html 에서 / 한글 타이핑되고 있는 글자를 얻으려고 하는 경우 / keydown / keyup / vue example / 타이핑하는 한글 가져오는 방법

js 에서 타이핑중인 글자를 얻는 방법

여기서는 compositeupdate event 를 이용한다. compositeupdate event 는 ref.1 을 참고하자.

만약 아래 code에서 ’한라산’을 typing 한다고 하면, 아래처럼 log 가 찍힌다.

new-query : ㅎ / input-value : 
new-query : 하 / input-value : ㅎ
new-query : 한 / input-value : 하
new-query : 한 / input-value : 한
new-query : ㄹ / input-value : 한
new-query : 한라 / input-value : 한ㄹ
new-query : 한랏 / input-value : 한라
new-query : 한라 / input-value : 한랏
new-query : 한사 / input-value : 한라
new-query : 한라산 / input-value : 한라사
<template>
  <input
    @compositionupdate="onCompositionUpdate"
  />
</template>

<script>
import { useMessage, NSelect } from 'naive-ui'

import api from '@/utils/api.js'

// emit: ['select']
const _ = {
  ...
  data() {
    curInput: '',
    ...
  },

  methods: {

    async onCompositionUpdate(event){
      const curInput = this.curInput
      const curCharTyping = event.data
      const newQuery = curInput + curCharTyping
      console.log(`new-query : ${newQuery} / input-value : ${curInput}`)
    },
    async onCompositionEnd(event){
      this.curInput = event.target.value   // done compostion character
    },
}

export default _
</script>

Reference

  1. Element: compositionupdate event - Web APIs | MDN

[컴] windows 에서 podman desktop 사용

 

도커 / 파드맨 /

windows 에서 podman desktop 사용

podman desktop 도 docker desktop 과 같다. wsl 로 linux vm image 를 하나 만들고, 그 안에서 container image들을 설치하고 실행시켜 준다.

좀더 사용해봐야 겠지만, 현재로선 podman desktop 을 사용하는 것이 podman-compose 를 사용하기는 조금 불편한 부분이 있지만, 충분히 docker desktop 을 대체할 수 있지 않을까 싶다.

설치

podman 이 windows 에 설치되면, CLI 와 guest Linux system 을 제공하게 된다. 이 guest Linux system 이 podman machine 이다. 이 podman machine 하나가 WSLv2 의 distribution 중 하나이다.(wsl -l 하면 볼 수 있다.)

그래서 이 podman 배포판에 접근하려면, wsl command 를 사용해도 되고, podman machine ssh 를 사용해도 된다.

  1. 설치
  2. podman machine init
  3. podman machine start

for rootful images

기본으로 만들어진 podman machine (wsl image) 은 root 권한이 아닌 상태로 동작한다. 그래서 새롭게 podman machine 을 만들면, 그 때 root 권한을 사용하도록 설정해서 만들수 있다.

Settings --> Resources --> Create new Podman Machine --> Machine with root privileges(Enabled)

그냥 root 권한이 아닌 podman machine 에서도 sudo 를 사용해서 image 를 만들고 사용할 수 있으나, podman desktop 에서 볼 수는 없다.

podman info

podman info 를 하면 아래처럼 보인다.

c:\Program Files\RedHat\Podman>podman info
host:
  arch: amd64
  buildahVersion: 1.30.0
  cgroupControllers: []
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: conmon-2.1.7-2.fc37.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.7, commit: '
  cpuUtilization:
    idlePercent: 99.87
    systemPercent: 0.1
    userPercent: 0.02
  cpus: 16
  databaseBackend: boltdb
  distribution:
    distribution: fedora
    variant: container
    version: "37"
  eventLogger: journald
  hostname: DESKTOP-TEST
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
  kernel: 5.10.102.1-microsoft-standard-WSL2
  linkmode: dynamic
  logDriver: journald
  memFree: 26482446336
  memTotal: 26834403328
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: crun-1.8.5-1.fc37.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.8.5
      commit: b6f80f766c9a89eb7b1440c0a70ab287434b17ed
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.0-8.fc37.x86_64
    version: |-
      slirp4netns version 1.2.0
      commit: 656041d45cfca7a4176f6b7eed9e4fe6c11e8383
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 7516192768
  swapTotal: 7516192768
  uptime: 0h 3m 41.00s
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /home/user/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/user/.local/share/containers/storage
  graphRootAllocated: 269490393088
  graphRootUsed: 703053824
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 0
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/user/.local/share/containers/storage/volumes
version:
  APIVersion: 4.5.0
  Built: 1681486976
  BuiltTime: Sat Apr 15 00:42:56 2023
  GitCommit: ""
  GoVersion: go1.19.7
  Os: linux
  OsArch: linux/amd64
  Version: 4.5.0


c:\Program Files\RedHat\Podman>

환경설정

아래 경로에서 configuration file 을 확인할 수 있다.

  • c:\Users\<user>\.config\containers\podman\machine\wsl\podman-machine-default.json

값의 변경은 다음처럼 podman machine을 이용해서 할 수 있다.

podman machine set --rootful=false

distro image path 변경

podman image 의 path 만 변경하면 된다. 이 안에 image 들이 저장되기 때문이다.

set tarFile=d:\a\vms\podman\podman-desktop-data.tar
set distro=podman-machine-default
set newPath=d:\a\vms\podman\data

wsl --export %distro% %tarFile%
wsl --unregister %distro%
wsl --import %distro% %newPath% %tarFile% --version 2

del %tarFile%

wsl --distribution %distro%

podman-compose

docker-compose대신에 podman-compose 를 사용할 수 있다. image 에 접속해서 podman-compose up 을 사용하면 된다. 그러면 podman desktop 에도 알아서 잡힌다. 일단 한번 잡히면, 계속 desktop 을 사용해서 실행할 수 있다.

podman machine ssh
sudo dnf install podman-compose

podman-compose -f compose.yaml up -d

See Also

  1. Run Docker in WSL (Windows 10/11) without Docker Desktop | by Sung Kim | Geek Culture | Medium

Reference

  1. 쿠…sal: [컴] docker 의 image path 변경하기
  2. 쿠…sal: [컴] wsl command
  3. podman-machine-set — Podman documentation