Open NAMAE client

Check-in [30dc17bfdc]
Login

Check-in [30dc17bfdc]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:設定値の変更と保存を実装
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA3-256: 30dc17bfdc85d76d0c8f03855e388a5e3061843835a4293e788da10d5ee28756
User & Date: kazuma 2024-05-25 21:01:28
Context
2024-05-26
00:45
ログファイルの仕様を追加 check-in: 4b6dabba76 user: kazuma tags: dev
2024-05-25
21:01
設定値の変更と保存を実装 check-in: 30dc17bfdc user: kazuma tags: dev
2024-05-24
22:50
GUIウインドウの実装 check-in: 613c6f88e0 user: kazuma tags: dev
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to artworks/Open_NAMAE_client.svg.

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
     inkscape:pageshadow="2"
     inkscape:pageopacity="0.0"
     inkscape:pagecheckerboard="false"
     inkscape:document-units="px"
     showgrid="false"
     units="px"
     inkscape:zoom="1.4142136"
     inkscape:cx="165.46299"
     inkscape:cy="112.42998"
     inkscape:window-width="1920"
     inkscape:window-height="1052"
     inkscape:window-x="1920"
     inkscape:window-y="0"
     inkscape:window-maximized="1"
     inkscape:current-layer="layer1"







|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
     inkscape:pageshadow="2"
     inkscape:pageopacity="0.0"
     inkscape:pagecheckerboard="false"
     inkscape:document-units="px"
     showgrid="false"
     units="px"
     inkscape:zoom="1.4142136"
     inkscape:cx="166.17009"
     inkscape:cy="112.42998"
     inkscape:window-width="1920"
     inkscape:window-height="1052"
     inkscape:window-x="1920"
     inkscape:window-y="0"
     inkscape:window-maximized="1"
     inkscape:current-layer="layer1"
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
       d="m 13.229167,13.229167 v 47.625 h 47.625 v -47.625 z M 18.520833,15.875 c 1.461254,0 2.645834,1.18458 2.645834,2.645833 1e-6,1.461254 -1.18458,2.645835 -2.645834,2.645834 -1.461253,0 -2.645833,-1.18458 -2.645833,-2.645834 0,-1.461253 1.18458,-2.645833 2.645833,-2.645833 z"
       sodipodi:nodetypes="cccccsssss" />
    <g
       id="g5"
       style="stroke:#ffffff;stroke-opacity:1;stroke-width:1.05833334"
       transform="translate(21.166665,21.166665)">
      <ellipse
         style="fill:#44bbdd;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291668;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:normal"
         id="path1"
         cx="15.875001"
         cy="15.875"
         rx="15.875001"
         ry="15.875" />
      <ellipse
         style="fill:#44bbdd;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291668;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:normal"
         id="path2"
         cx="15.875001"
         cy="15.875001"
         rx="7.9375005"
         ry="15.875001" />
      <path
         style="fill:#333333;stroke:#ffffff;stroke-width:1.32291668;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:markers stroke fill"







|






|







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
       d="m 13.229167,13.229167 v 47.625 h 47.625 v -47.625 z M 18.520833,15.875 c 1.461254,0 2.645834,1.18458 2.645834,2.645833 1e-6,1.461254 -1.18458,2.645835 -2.645834,2.645834 -1.461253,0 -2.645833,-1.18458 -2.645833,-2.645834 0,-1.461253 1.18458,-2.645833 2.645833,-2.645833 z"
       sodipodi:nodetypes="cccccsssss" />
    <g
       id="g5"
       style="stroke:#ffffff;stroke-opacity:1;stroke-width:1.05833334"
       transform="translate(21.166665,21.166665)">
      <ellipse
         style="fill:#33bbdd;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291668;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:normal"
         id="path1"
         cx="15.875001"
         cy="15.875"
         rx="15.875001"
         ry="15.875" />
      <ellipse
         style="fill:#33bbdd;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291668;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:normal"
         id="path2"
         cx="15.875001"
         cy="15.875001"
         rx="7.9375005"
         ry="15.875001" />
      <path
         style="fill:#333333;stroke:#ffffff;stroke-width:1.32291668;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:markers stroke fill"

Changes to artworks/Open_NAMAE_client.webp.

cannot compute difference between binary files

Changes to artworks/Open_NAMAE_client_logo.svg.

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
     inkscape:pageshadow="2"
     inkscape:pageopacity="0.0"
     inkscape:pagecheckerboard="false"
     inkscape:document-units="px"
     showgrid="false"
     units="px"
     inkscape:zoom="1.4142136"
     inkscape:cx="331.63308"
     inkscape:cy="136.47161"
     inkscape:window-width="1920"
     inkscape:window-height="1052"
     inkscape:window-x="1920"
     inkscape:window-y="0"
     inkscape:window-maximized="1"
     inkscape:current-layer="layer1"
     inkscape:showpageshadow="2"
     inkscape:deskcolor="#d1d1d1" />
  <defs
     id="defs2" />
  <g
     inkscape:label="レイヤー 1"
     inkscape:groupmode="layer"
     id="layer1">
    <path
       id="rect5"
       style="fill:#33bbdd;fill-opacity:1;stroke:none;stroke-width:1.05833;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;paint-order:normal"
       d="m 18.520834,13.229167 v 47.625 h 47.625 v -47.625 z M 23.8125,15.875 c 1.461254,0 2.645834,1.18458 2.645834,2.645833 1e-6,1.461254 -1.18458,2.645835 -2.645834,2.645834 -1.461253,0 -2.645833,-1.18458 -2.645833,-2.645834 0,-1.461253 1.18458,-2.645833 2.645833,-2.645833 z"
       sodipodi:nodetypes="cccccsssss" />
    <g
       id="g5"
       style="stroke:#ffffff;stroke-width:1.05833;stroke-opacity:1"
       transform="translate(26.458332,21.166665)">
      <ellipse
         style="fill:#44bbdd;fill-opacity:1;stroke:#ffffff;stroke-width:1.32292;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:normal"
         id="path1"
         cx="15.875001"
         cy="15.875"
         rx="15.875001"
         ry="15.875" />
      <ellipse
         style="fill:#44bbdd;fill-opacity:1;stroke:#ffffff;stroke-width:1.32292;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:normal"
         id="path2"
         cx="15.875001"
         cy="15.875001"
         rx="7.9375005"
         ry="15.875001" />
      <path
         style="fill:#333333;stroke:#ffffff;stroke-width:1.32292;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:markers stroke fill"







|


|
|


|


















|






|







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
     inkscape:pageshadow="2"
     inkscape:pageopacity="0.0"
     inkscape:pagecheckerboard="false"
     inkscape:document-units="px"
     showgrid="false"
     units="px"
     inkscape:zoom="1.4142136"
     inkscape:cx="331.98662"
     inkscape:cy="136.47161"
     inkscape:window-width="1920"
     inkscape:window-height="1008"
     inkscape:window-x="0"
     inkscape:window-y="0"
     inkscape:window-maximized="1"
     inkscape:current-layer="g5"
     inkscape:showpageshadow="2"
     inkscape:deskcolor="#d1d1d1" />
  <defs
     id="defs2" />
  <g
     inkscape:label="レイヤー 1"
     inkscape:groupmode="layer"
     id="layer1">
    <path
       id="rect5"
       style="fill:#33bbdd;fill-opacity:1;stroke:none;stroke-width:1.05833;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;paint-order:normal"
       d="m 18.520834,13.229167 v 47.625 h 47.625 v -47.625 z M 23.8125,15.875 c 1.461254,0 2.645834,1.18458 2.645834,2.645833 1e-6,1.461254 -1.18458,2.645835 -2.645834,2.645834 -1.461253,0 -2.645833,-1.18458 -2.645833,-2.645834 0,-1.461253 1.18458,-2.645833 2.645833,-2.645833 z"
       sodipodi:nodetypes="cccccsssss" />
    <g
       id="g5"
       style="stroke:#ffffff;stroke-width:1.05833;stroke-opacity:1"
       transform="translate(26.458332,21.166665)">
      <ellipse
         style="fill:#33bbdd;fill-opacity:1;stroke:#ffffff;stroke-width:1.32292;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:normal"
         id="path1"
         cx="15.875001"
         cy="15.875"
         rx="15.875001"
         ry="15.875" />
      <ellipse
         style="fill:#32bbdd;fill-opacity:1;stroke:#ffffff;stroke-width:1.32292;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:normal"
         id="path2"
         cx="15.875001"
         cy="15.875001"
         rx="7.9375005"
         ry="15.875001" />
      <path
         style="fill:#333333;stroke:#ffffff;stroke-width:1.32292;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;paint-order:markers stroke fill"

Changes to artworks/Open_NAMAE_client_logo.webp.

cannot compute difference between binary files

Changes to open_namae_client/files/icon.ico.

cannot compute difference between binary files

Changes to open_namae_client/files/icon.png.

cannot compute difference between binary files

Changes to open_namae_client/open_namae_gui.py.

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













































83
84
85
86

87
88
89
except:
    config = {
        "onamae_id" : "",
        "password" : "",
        "ip_address_api" : "http://ifconfig.example.jp/",
        "dns_host" : "ddnsclient.onamae.com",
        "dns_port" : 65010,
        "domains" : []








    }


def open_main_window ():
    global config
    global is_windows
    global main_win






    
    main_win = tk.Tk()
    
    main_win.title(APP_NAME + " v" + APP_VERSION)
    main_win.geometry("480x480")
    main_win.resizable(0, 0)
    main_win.configure(bg="#ffffff")
    
    main_win.protocol("WM_DELETE_WINDOW", close_main_window)
    
    if is_windows:
        main_win.iconbitmap("files/icon.ico")
        
        label_font = tk.font.Font(family="Yu Gothic", size=12)
        button_font = tk.font.Font(family="Yu Gothic", size=11)
    else:
        main_win.iconphoto(True, tk.PhotoImage(file="files/icon.png"))
        
        label_font = tk.font.Font(size=12)
        button_font = tk.font.Font(size=10)
























































    
    main_win.mainloop()


def close_main_window ():
    global config
    global main_win
    













































    with open("config.json", "w", encoding="utf-8") as json_fp:
        json.dump(config, json_fp, ensure_ascii=False, indent=4)
    
    main_win.destroy()



open_main_window()







|
>
>
>
>
>
>
>
>







>
>
>
>
>
>



|









|
|



|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



<
>



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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200

201
202
203
204
except:
    config = {
        "onamae_id" : "",
        "password" : "",
        "ip_address_api" : "http://ifconfig.example.jp/",
        "dns_host" : "ddnsclient.onamae.com",
        "dns_port" : 65010,
        "domains" : [
            {
                "domain_name" : "example1.jp"
            },
            {
                "host_name" : "www",
                "domain_name" : "example2.jp"
            }
        ]
    }


def open_main_window ():
    global config
    global is_windows
    global main_win
    global entry_onamae_id
    global entry_password
    global entry_ip_address_api
    global entry_dns_host
    global entry_dns_port
    global domains_area
    
    main_win = tk.Tk()
    
    main_win.title(APP_NAME + " コントロールパネル v" + APP_VERSION)
    main_win.geometry("480x480")
    main_win.resizable(0, 0)
    main_win.configure(bg="#ffffff")
    
    main_win.protocol("WM_DELETE_WINDOW", close_main_window)
    
    if is_windows:
        main_win.iconbitmap("files/icon.ico")
        
        label_font = tk.font.Font(family="Yu Gothic", size=11)
        entry_font = tk.font.Font(family="Yu Gothic", size=10)
    else:
        main_win.iconphoto(True, tk.PhotoImage(file="files/icon.png"))
        
        label_font = tk.font.Font(size=10)
        entry_font = tk.font.Font(size=9)
    
    label_onamae_id = tk.Label(main_win, text="お名前ID:", font=label_font, fg="#333333", bg="#ffffff")
    label_onamae_id.place(x=10, y=60)
    
    entry_onamae_id = tk.Entry(main_win, width=20, font=entry_font, fg="#333333", bg="#ffffff", bd=1, relief="solid")
    entry_onamae_id.insert(0, config["onamae_id"])
    entry_onamae_id.place(x=75, y=60)
    
    label_password = tk.Label(main_win, text="パスワード:", font=label_font, fg="#333333", bg="#ffffff")
    label_password.place(x=240, y=60)
    
    entry_password = tk.Entry(main_win, show="*", width=20, font=entry_font, fg="#333333", bg="#ffffff", bd=1, relief="solid")
    entry_password.insert(0, config["password"])
    entry_password.place(x=315, y=60)
    
    label_ip_address_api = tk.Label(main_win, text="グローバルIP確認URL:", font=label_font, fg="#333333", bg="#ffffff")
    label_ip_address_api.place(x=10, y=100)
    
    entry_ip_address_api = tk.Entry(main_win, width=40, font=entry_font, fg="#333333", bg="#ffffff", bd=1, relief="solid")
    entry_ip_address_api.insert(0, config["ip_address_api"])
    entry_ip_address_api.place(x=155, y=100)
    
    label_dns_host = tk.Label(main_win, text="DDNSホスト:", font=label_font, fg="#333333", bg="#ffffff")
    label_dns_host.place(x=10, y=140)
    
    entry_dns_host = tk.Entry(main_win, width=25, font=entry_font, fg="#333333", bg="#ffffff", bd=1, relief="solid")
    entry_dns_host.insert(0, config["dns_host"])
    entry_dns_host.place(x=100, y=140)
    
    label_dns_port = tk.Label(main_win, text="DDNSポート:", font=label_font, fg="#333333", bg="#ffffff")
    label_dns_port.place(x=290, y=140)
    
    entry_dns_port = tk.Entry(main_win, width=10, font=entry_font, fg="#333333", bg="#ffffff", bd=1, relief="solid")
    entry_dns_port.insert(0, config["dns_port"])
    entry_dns_port.place(x=380, y=140)
    
    label_domains = tk.Label(main_win, text="ドメイン (ホスト名とドメイン名はセミコロンで区切って入力)", font=label_font, fg="#333333", bg="#ffffff")
    label_domains.place(x=10, y=190)
    
    domains_area_scroll_y = tk.Scrollbar(main_win, orient="vertical", bg="#eeeeee", activebackground="#ffffff")
    domains_area = tk.Text(main_win, font=entry_font, fg="#333333", bg="#ffffff", padx=5, pady=5, relief="solid", yscrollcommand=domains_area_scroll_y.set)
    domains_area_scroll_y["command"] = domains_area.yview
    domains_area.place(x=15, y=220, width=435, height=180)
    domains_area_scroll_y.place(x=450, y=220, width=15, height=180)
    
    for domain_data in config["domains"]:
        if "host_name" in domain_data:
            domains_area.insert(tk.END, domain_data["host_name"] + ";" + domain_data["domain_name"] + "\n")
        else:
            domains_area.insert(tk.END, domain_data["domain_name"] + "\n")
    
    dns_update_button = tk.Button(main_win, text="この設定でDNS情報を更新", font=entry_font, fg="#ffffff", bg="#33bbdd", relief="flat", highlightbackground="#33bbdd", activeforeground="#ffffff", activebackground="#aaeeff")
    dns_update_button.place(x=70, y=420, width=200, height=40)
    
    save_button = tk.Button(main_win, text="変更を適用", font=entry_font, command=save_config, fg="#ffffff", bg="#33bbdd", relief="flat", highlightbackground="#33bbdd", activeforeground="#ffffff", activebackground="#aaeeff")
    save_button.place(x=290, y=420, width=120, height=40)
    
    main_win.mainloop()


def close_main_window ():
    global config
    global main_win
    
    if messagebox.askokcancel(APP_NAME , APP_NAME + "の設定を終了しますか?"):
        main_win.destroy()


def update_config ():
    global config
    global entry_onamae_id
    global entry_password
    global entry_ip_address_api
    global entry_dns_host
    global entry_dns_port
    global domains_area
    
    config["onamae_id"] = entry_onamae_id.get()
    config["password"] = entry_password.get()
    config["ip_address_api"] = entry_ip_address_api.get()
    config["dns_host"] = entry_dns_host.get()
    config["dns_port"] = int(entry_dns_port.get())
    
    config["domains"] = []
    domains = domains_area.get("1.0", tk.END).split()
    for domain_str in domains:
        domain_str = domain_str.strip()
        
        if len(domain_str) == 0:
            continue
        
        domain_data = domain_str.split(";")
        
        if len(domain_data) == 1:
            config["domains"].append({
                "domain_name" : domain_str
            })
        else:
            config["domains"].append({
                "host_name" : domain_data[0].strip(),
                "domain_name" : domain_data[-1].strip()
            })


def save_config ():
    global config
    
    update_config()
    
    with open("config.json", "w", encoding="utf-8") as json_fp:
        json.dump(config, json_fp, ensure_ascii=False, indent=4)
    

    messagebox.showinfo(APP_NAME ,"設定を保存しました")


open_main_window()