Require APRS passcode for raw APRS usage

This commit is contained in:
Jordan Sherer 2018-09-05 11:33:50 -04:00
parent f30cf20400
commit e922df7635
6 changed files with 40 additions and 15 deletions

View File

@ -194,17 +194,11 @@ void APRSISClient::enqueueSpot(QString theircall, QString grid, QString comment)
enqueueRaw(spotFrame);
}
void APRSISClient::enqueueMessage(QString tocall, QString message){
if(m_localCall.isEmpty()) return;
auto messageFrame = QString("%1>APRS,TCPIP*::%2:%3\n");
messageFrame = messageFrame.arg(m_localCall);
messageFrame = messageFrame.arg(tocall + QString(" ").repeated(9-tocall.length()));
messageFrame = messageFrame.arg(message);
enqueueRaw(messageFrame);
}
void APRSISClient::enqueueThirdParty(QString theircall, QString payload){
if(m_localPasscode != hashCallsign(m_localCall)){
return;
}
auto frame = QString("%1>%2,APRS,TCPIP*:%3\n");
frame = frame.arg(theircall);
frame = frame.arg(m_localCall);

View File

@ -29,13 +29,15 @@ public:
m_paused = paused;
}
void setLocalStation(QString mycall, QString mygrid){
void setLocalStation(QString mycall, QString mygrid, QString passcode){
m_localCall = mycall;
m_localGrid = mygrid;
m_localPasscode = passcode;
}
bool isPasscodeValid(){ return m_localPasscode == QString::number(hashCallsign(m_localCall)); }
void enqueueSpot(QString theircall, QString grid, QString comment);
void enqueueMessage(QString tocall, QString message);
void enqueueThirdParty(QString theircall, QString payload);
void enqueueRaw(QString aprsFrame);
@ -51,6 +53,7 @@ public slots:
private:
QString m_localCall;
QString m_localGrid;
QString m_localPasscode;
QQueue<QString> m_frameQueue;
QString m_host;

View File

@ -607,6 +607,7 @@ private:
QString opCall_;
QString aprs_server_name_;
QString aprs_passcode_;
port_type aprs_server_port_;
QString udp_server_name_;
@ -725,6 +726,7 @@ bool Configuration::split_mode () const {return m_->split_mode ();}
QString Configuration::opCall() const {return m_->opCall_;}
QString Configuration::aprs_server_name () const {return m_->aprs_server_name_;}
auto Configuration::aprs_server_port () const -> port_type {return m_->aprs_server_port_;}
QString Configuration::aprs_passcode() const { return m_->aprs_passcode_; }
QString Configuration::udp_server_name () const {return m_->udp_server_name_;}
auto Configuration::udp_server_port () const -> port_type {return m_->udp_server_port_;}
bool Configuration::accept_udp_requests () const {return m_->accept_udp_requests_;}
@ -1307,6 +1309,7 @@ void Configuration::impl::initialize_models ()
ui_->opCallEntry->setText (opCall_);
ui_->aprs_server_line_edit->setText (aprs_server_name_);
ui_->aprs_server_port_spin_box->setValue (aprs_server_port_);
ui_->aprs_passcode_line_edit->setText(aprs_passcode_);
ui_->udp_server_line_edit->setText (udp_server_name_);
ui_->udp_server_port_spin_box->setValue (udp_server_port_);
ui_->accept_udp_requests_check_box->setChecked (accept_udp_requests_);
@ -1533,6 +1536,7 @@ void Configuration::impl::read_settings ()
opCall_ = settings_->value ("OpCall", "").toString ();
aprs_server_name_ = settings_->value ("aprsServer", "rotate.aprs2.net").toString ();
aprs_server_port_ = settings_->value ("aprsServerPort", 14580).toUInt ();
aprs_passcode_ = settings_->value ("aprsPasscode", "").toString();
udp_server_name_ = settings_->value ("UDPServer", "127.0.0.1").toString ();
udp_server_port_ = settings_->value ("UDPServerPort", 2237).toUInt ();
n1mm_server_name_ = settings_->value ("N1MMServer", "127.0.0.1").toString ();
@ -1648,6 +1652,7 @@ void Configuration::impl::write_settings ()
settings_->setValue ("OpCall", opCall_);
settings_->setValue ("aprsServer", aprs_server_name_);
settings_->setValue ("aprsServerPort", aprs_server_port_);
settings_->setValue ("aprsPasscode", aprs_passcode_);
settings_->setValue ("UDPServer", udp_server_name_);
settings_->setValue ("UDPServerPort", udp_server_port_);
settings_->setValue ("N1MMServer", n1mm_server_name_);
@ -2070,6 +2075,7 @@ void Configuration::impl::accept ()
aprs_server_name_ = ui_->aprs_server_line_edit->text();
aprs_server_port_ = ui_->aprs_server_port_spin_box->value();
aprs_passcode_ = ui_->aprs_passcode_line_edit->text();
auto newUdpEnabled = ui_->udpEnable->isChecked();
auto new_server = ui_->udp_server_line_edit->text ();

View File

@ -150,6 +150,7 @@ public:
QString opCall() const;
QString aprs_server_name () const;
port_type aprs_server_port () const;
QString aprs_passcode () const;
QString udp_server_name () const;
port_type udp_server_port () const;
QString n1mm_server_name () const;

View File

@ -2104,6 +2104,19 @@ for assessing propagation and system performance.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_16">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;APRS Server Passcode for Sending APRS Packets&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>APRS Passcode:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="aprs_passcode_line_edit"/>
</item>
</layout>
</item>
</layout>

View File

@ -1210,10 +1210,12 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
connect(ui->tableWidgetRXAll->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::on_tableWidgetRXAll_selectionChanged);
connect(ui->tableWidgetCalls->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::on_tableWidgetCalls_selectionChanged);
// Don't block beacon's first run...
m_lastTxTime = QDateTime::currentDateTimeUtc().addSecs(-300);
pskSetLocal();
aprsSetLocal();
displayActivity(true);
#if 0
@ -6323,6 +6325,11 @@ QStringList MainWindow::buildFT8MessageFrames(QString const& text){
}
qDebug() << "after:" << line;
}
// APRS:
if(dirCmd.trimmed() == "APRS:" && !m_aprsClient->isPasscodeValid()){
MessageBox::warning_message(this, tr ("Please enter a valid APRS passcode in the settings to send an APRS packet."));
}
}
if(useDat){
@ -8414,6 +8421,7 @@ void MainWindow::aprsSetLocal ()
auto call = m_config.my_callsign();
auto base = Radio::base_callsign(call);
auto grid = m_config.my_grid();
auto passcode = m_config.aprs_passcode();
#if SPOT_SSID_SUFFIX
if(call != base){
@ -8428,8 +8436,8 @@ void MainWindow::aprsSetLocal ()
}
#endif
qDebug() << "APRSISClient Set Local Station:" << base << grid;
m_aprsClient->setLocalStation(base, grid);
qDebug() << "APRSISClient Set Local Station:" << base << grid << passcode;
m_aprsClient->setLocalStation(base, grid, passcode);
}
void MainWindow::transmitDisplay (bool transmitting)