Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-7831
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Oct 6, 2023
1 parent 60860ad commit 432434a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 43 deletions.
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
33
35
1 change: 1 addition & 0 deletions openapi/owgw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,7 @@ components:
- generic
- orion
- globalreach
- radsec
default:
generic
poolProxyIp:
Expand Down
102 changes: 61 additions & 41 deletions src/RADIUS_proxy_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,46 +107,59 @@ namespace OpenWifi {
void RADIUS_proxy_server::Stop() {
if (Enabled_ && Running_) {
poco_information(Logger(), "Stopping...");
RadiusReactor_->removeEventHandler(
*AuthenticationSocketV4_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnAuthenticationSocketReadable));
RadiusReactor_->removeEventHandler(
*AuthenticationSocketV6_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnAuthenticationSocketReadable));

RadiusReactor_->removeEventHandler(
*AccountingSocketV4_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnAccountingSocketReadable));
RadiusReactor_->removeEventHandler(
*AccountingSocketV6_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnAccountingSocketReadable));

RadiusReactor_->removeEventHandler(
*CoASocketV4_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnCoASocketReadable));
RadiusReactor_->removeEventHandler(
*CoASocketV6_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnCoASocketReadable));

AuthenticationSocketV4_->close();
AuthenticationSocketV6_->close();
AccountingSocketV4_->close();
AccountingSocketV6_->close();
CoASocketV4_->close();
CoASocketV6_->close();

AuthenticationSocketV4_.reset();
AuthenticationSocketV6_.reset();
AccountingSocketV4_.reset();
AccountingSocketV6_.reset();
CoASocketV4_.reset();
CoASocketV6_.reset();

if(AuthenticationSocketV4_) {
RadiusReactor_->removeEventHandler(
*AuthenticationSocketV4_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnAuthenticationSocketReadable));
AuthenticationSocketV4_->close();
AuthenticationSocketV4_.reset();
}

if(AuthenticationSocketV6_) {
RadiusReactor_->removeEventHandler(
*AuthenticationSocketV6_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnAuthenticationSocketReadable));
AuthenticationSocketV6_->close();
AuthenticationSocketV6_.reset();
}

if(AccountingSocketV4_) {
RadiusReactor_->removeEventHandler(
*AccountingSocketV4_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnAccountingSocketReadable));
AccountingSocketV4_->close();
AccountingSocketV4_.reset();
}
if(AccountingSocketV6_) {
RadiusReactor_->removeEventHandler(
*AccountingSocketV6_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnAccountingSocketReadable));
AccountingSocketV6_->close();
AccountingSocketV6_.reset();
}

if(CoASocketV4_) {
RadiusReactor_->removeEventHandler(
*CoASocketV4_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnCoASocketReadable));
CoASocketV4_->close();
CoASocketV4_.reset();
}

if(CoASocketV6_) {
RadiusReactor_->removeEventHandler(
*CoASocketV6_,
Poco::NObserver<RADIUS_proxy_server, Poco::Net::ReadableNotification>(
*this, &RADIUS_proxy_server::OnCoASocketReadable));
CoASocketV6_->close();
CoASocketV6_.reset();
}

StopRADSECServers();
RadiusReactor_->stop();
Expand All @@ -156,10 +169,14 @@ namespace OpenWifi {
}
}

inline static bool isRadsec(const GWObjects::RadiusProxyPool &Cfg) {
return Cfg.radsecPoolType=="orion" || Cfg.radsecPoolType=="globalreach" || Cfg.radsecPoolType=="radsec";
}

void RADIUS_proxy_server::StartRADSECServers() {
std::lock_guard G(Mutex_);
for (const auto &pool : PoolList_.pools) {
if(pool.enabled) {
if(pool.enabled && isRadsec(pool)) {
for (const auto &entry : pool.authConfig.servers) {
if (entry.radsec) {
RADSECservers_[Poco::Net::SocketAddress(entry.ip, 0)] =
Expand Down Expand Up @@ -265,6 +282,9 @@ namespace OpenWifi {
Poco::Net::SocketAddress Dst(Destination);

std::lock_guard G(Mutex_);

// are we sending this to a pool?

bool UseRADSEC = false;
auto FinalDestination = Route(radius_type::acct, Dst, P, UseRADSEC, secret);
if (UseRADSEC) {
Expand Down
2 changes: 1 addition & 1 deletion src/RESTAPI/RESTAPI_radiusProxyConfig_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace OpenWifi {

static bool ValidRadiusPoolServerType(const std::string &T) {
static std::set<std::string> Types{ "generic", "orion", "globalreach"};
static std::set<std::string> Types{ "radsec", "generic", "orion", "globalreach"};
return Types.find(T)!=Types.end();
}

Expand Down

0 comments on commit 432434a

Please sign in to comment.