Created
October 22, 2017 16:31
-
-
Save angelsl/0cd031a96528a940cafe15a9472105ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2004-2017 ZNC, see the NOTICE file for details. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
#include <znc/znc.h> | |
class CAllowLocalhost : public CModule { | |
public: | |
MODCONSTRUCTOR(CAllowLocalhost) {} | |
~CAllowLocalhost() override {} | |
EModRet OnLoginAttempt(std::shared_ptr<CAuthBase> Auth) override { | |
const CString sUser = Auth->GetUsername(); | |
Csock* pSock = Auth->GetSocket(); | |
CUser* pUser = CZNC::Get().FindUser(sUser); | |
if (pSock == nullptr || pUser == nullptr) return CONTINUE; | |
if (pSock->GetRemoteIP() == "127.0.0.1") { | |
Auth->AcceptLogin(*pUser); | |
return HALT; | |
} | |
return CONTINUE; | |
} | |
}; | |
GLOBALMODULEDEFS( | |
CAllowLocalhost, | |
"Allows localhost to auth without password.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment