Skip to content

Commit

Permalink
fix(Settings): Don't allow invalid proxy hosts in settings.
Browse files Browse the repository at this point in the history
For simplicity (and because we don't want to do DNS resolution), we now
only allow IP addresses here.
  • Loading branch information
iphydf committed Feb 5, 2025
1 parent 681144b commit b54e858
Show file tree
Hide file tree
Showing 56 changed files with 557 additions and 5 deletions.
14 changes: 12 additions & 2 deletions src/persistence/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,19 @@ bool Settings::verifyProxySettings(const QCommandLineParser& parser)
return false;
}

// TODO(iphydf): Sanity check IPv4/IPv6 addresses/hostnames
// Sanity check IPv4/IPv6 addresses/hostnames
const QHostAddress proxyAddress{proxySettingStrings[1]};
if (proxyAddress.isNull()) {
qCritical() << "Invalid proxy address" << proxySettingStrings[1]
<< "- only IPv4/IPv6 addresses are supported.";
return false;
}

const int portNumber = proxySettingStrings[2].toInt();
bool ok;
const int portNumber = proxySettingStrings[2].toInt(&ok);
if (!ok) {
qCritical() << "Invalid port number" << proxySettingStrings[2] << "- must be an integer.";
}
if (portNumber < 1 || portNumber > 65535) {
qCritical() << "Invalid port number range: was" << portNumber << "but should be 1-65535.";
}
Expand Down
8 changes: 8 additions & 0 deletions src/widget/form/settings/advancedform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <QClipboard>
#include <QDir>
#include <QFileDialog>
#include <QHostAddress>
#include <QMessageBox>
#include <QProcess>

Expand Down Expand Up @@ -187,6 +188,13 @@ void AdvancedForm::on_cbEnableLanDiscovery_stateChanged()

void AdvancedForm::on_proxyAddr_editingFinished()
{
const QHostAddress addr{bodyUI->proxyAddr->text()};
if (addr.isNull()) {
messageBoxManager
.showError(tr("Invalid proxy address"),
tr("Please enter a valid IP address. Hostnames are not supported."));
return;
}
settings.setProxyAddr(bodyUI->proxyAddr->text());
}

Expand Down
10 changes: 10 additions & 0 deletions translations/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,16 @@ which may lead to problems with video calls.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">احفظ الملف</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">عنوان الوكيل غير صالح</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">الرجاء إدخال عنوان IP صالح. أسماء المضيف غير مدعومة.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/be.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,16 @@ which may lead to problems with video calls.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Захаваць файл</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Несапраўдны проксі -адрас</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Калі ласка, увядзіце сапраўдны IP -адрас. Імёны хастоў не падтрымліваюцца.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/ber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,16 @@ which may lead to problems with video calls.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">ⵃⵔⴻⵣ ⴰⴼⴰⵢⵍⵓ</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">ⵜⴰⵏⵙⴰ ⵏ ⴱⵔⵓⴽⵙⵉⵍ ⵓⵔ ⵉⵏⵏⴼⵍⵏ</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">ⴰⵔ ⵜⵜⵔⵖ ⴰⴷ ⵜⴽⵛⵎⴷ ⵙ ⵢⴰⵏ ⵓⵏⵙⴰ ⵏ IP ⵉⵣⴷⴷⵉⴳⵏ. ⵉⵙⵎⴰⵡⵏ ⵏ ⵀⵓⵙⵜ ⵓⵔ ⵜⵜⵓⵙⴷⵓⵙⵏ.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,16 @@ which may lead to problems with video calls.</source>
<source>Save file</source>
<translation>Запазване на файла</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Невалиден прокси адрес</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Моля, въведете валиден IP адрес. Името на хоста не се поддържа.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/bn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,16 @@ which may lead to problems with video calls.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">ফাইল সংরক্ষণ করুন</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">অবৈধ প্রক্সি ঠিকানা</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">একটি বৈধ আইপি ঠিকানা লিখুন দয়া করে। হোস্টনামগুলি সমর্থিত নয়।</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,16 @@ může dojít během video hovoru k výpadkům či jiným problémům.</translat
<source>Save file</source>
<translation>Uložit soubor</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Neplatná adresa proxy</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Zadejte platnou IP adresu. Názvy hostitelů nejsou podporovány.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,16 @@ hvilket kan føre til problemer med videoopkald.</translation>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Gem fil</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Ugyldig proxyadresse</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Indtast en gyldig IP -adresse. Værtsnavne understøttes ikke.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,16 @@ dadurch kann es zu Problemen bei Videoanrufen kommen.</translation>
<source>Save file</source>
<translation>Datei speichern</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Ungültige Proxy -Adresse</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Bitte geben Sie eine gültige IP -Adresse ein. Hostnamen werden nicht unterstützt.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,16 @@ which may lead to problems with video calls.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Αποθήκευση αρχείου</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Μη έγκυρη διεύθυνση πληρεξούσιου</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Εισαγάγετε μια έγκυρη διεύθυνση IP. Τα ονόματα κεντρικού υπολογιστή δεν υποστηρίζονται.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/eo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,16 @@ kio povas konduki al problemoj kun videovokoj.</translation>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Konservu dosieron</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Nevalida prokura adreso</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Bonvolu enigi validan IP -adreson. Hostnames ne estas subtenataj.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,16 @@ lo que puede provocar problemas en las videollamadas.</translation>
<source>Save file</source>
<translation>Guardar archivo</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Dirección proxy no válida</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Ingrese una dirección IP válida. Los nombres de host no son compatibles.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/et.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,16 @@ mis võib põhjustada probleeme videokõnedega.</translation>
<source>Save file</source>
<translation>Salvesta fail</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Kehtetu puhverserveri aadress</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Sisestage kehtiv IP -aadress. Hostinimesid ei toetata.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,16 @@ which may lead to problems with video calls.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">ذخیره فایل</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">آدرس پروکسی نامعتبر</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">لطفاً یک آدرس IP معتبر وارد کنید. نام های میزبان پشتیبانی نمی شوند.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,16 @@ mikä voi johtaa ongelmiin videopuheluissa.</translation>
<source>Save file</source>
<translation>Tallenna tiedosto</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Virheellinen välityspalvelinosoite</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Anna kelvollinen IP -osoite. Isäntänimejä ei tueta.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,16 @@ ce qui peut entraîner des problèmes lors des appels vidéo.</translation>
<source>Save file</source>
<translation>Enregistrer le fichier</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Adresse proxy non valide</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Veuillez saisir une adresse IP valide. Les noms d&apos;hôte ne sont pas pris en charge.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/gl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,16 @@ o que pode provocar problemas coas videochamadas.</translation>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Gardar ficheiro</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Enderezo de proxy non válido</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Insira un enderezo IP válido. Os nomes de host non son compatibles.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,16 @@ which may lead to problems with video calls.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">שמור קובץ</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">כתובת פרוקסי לא חוקית</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">אנא הזן כתובת IP תקפה. שמות מארחים אינם נתמכים.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/hr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,16 @@ Ponekad vaša veza možda nije dovoljno dobra da podnese višu kvalitetu videa,
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Spremi datoteku</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Nevažeća proxy adresa</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Unesite valjanu IP adresu. Nazivi domaćina nisu podržana.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,16 @@ ami problémákat okozhat a videohívásokkal kapcsolatban.</translation>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Fájl mentése</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Érvénytelen proxy cím</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Kérjük, írjon be egy érvényes IP -címet. A gazdagépnevek nem támogatottak.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
10 changes: 10 additions & 0 deletions translations/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,16 @@ sem getur leitt til vandræða með myndsímtöl.</translation>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Vista skrá</translation>
</message>
<message>
<source>Invalid proxy address</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Ógilt umboð heimilisfang</translation>
</message>
<message>
<source>Please enter a valid IP address. Hostnames are not supported.</source>
<translatorcomment>Automated translation.</translatorcomment>
<translation type="unfinished">Vinsamlegast sláðu inn gilt IP -tölu. Hostnames eru ekki studd.</translation>
</message>
</context>
<context>
<name>AdvancedSettings</name>
Expand Down
Loading

0 comments on commit b54e858

Please sign in to comment.