|
157 | 157 | const [endpoint, setEndpoint] = useState(location.href + "connect.php"); |
158 | 158 | const [port, setPort] = useState("10022"); |
159 | 159 | const [destination, setDestination] = useState("linuxserver.io@localhost"); |
| 160 | + const [password, setPassword] = useState(""); |
160 | 161 | const [key, setKey] = useState(""); |
161 | 162 | const [copied, setCopied] = useState(false); |
162 | 163 |
|
|
168 | 169 | const url = new URL(base); |
169 | 170 | url.searchParams.set("port", port); |
170 | 171 | url.searchParams.set("destination", destination); |
171 | | - url.searchParams.set("key", key); |
| 172 | + if (password.trim()) { |
| 173 | + url.searchParams.set("password", password); |
| 174 | + } else { |
| 175 | + url.searchParams.delete("password"); |
| 176 | + } |
| 177 | + |
| 178 | + if (key.trim()) { |
| 179 | + url.searchParams.set("key", key); |
| 180 | + } else { |
| 181 | + url.searchParams.delete("key"); |
| 182 | + } |
172 | 183 | return url.toString(); |
173 | 184 | } catch { |
174 | 185 | return ""; |
175 | 186 | } |
176 | | - }, [endpoint, port, destination, key]); |
| 187 | + }, [endpoint, port, destination, password, key]); |
177 | 188 |
|
178 | 189 | const handleCopy = async () => { |
179 | 190 | if (!generatedUrl) return; |
@@ -223,12 +234,22 @@ <h1>SSH Link Generator</h1> |
223 | 234 | /> |
224 | 235 | </label> |
225 | 236 |
|
| 237 | + <label> |
| 238 | + Password |
| 239 | + <input |
| 240 | + type="password" |
| 241 | + value={password} |
| 242 | + onChange={(e) => setPassword(e.target.value)} |
| 243 | + placeholder="接続パスワード(任意)" |
| 244 | + /> |
| 245 | + </label> |
| 246 | + |
226 | 247 | <label> |
227 | 248 | Key |
228 | 249 | <textarea |
229 | 250 | value={key} |
230 | 251 | onChange={(e) => setKey(e.target.value)} |
231 | | - placeholder="秘密鍵の文字列" |
| 252 | + placeholder="秘密鍵の文字列(任意)" |
232 | 253 | /> |
233 | 254 | </label> |
234 | 255 | </div> |
|
0 commit comments