XRootD
XrdXrootdRedirHelper.hh
Go to the documentation of this file.
1 #ifndef __XRDXROOTDREDIRHELPER__
2 #define __XRDXROOTDREDIRHELPER__
3 /******************************************************************************/
4 /* */
5 /* X r d X r o o t d R e d i r H e l p e r . h h */
6 /* */
7 /* (c) 2026 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* */
9 /* This file is part of the XRootD software suite. */
10 /* */
11 /* XRootD is free software: you can redistribute it and/or modify it under */
12 /* the terms of the GNU Lesser General Public License as published by the */
13 /* Free Software Foundation, either version 3 of the License, or (at your */
14 /* option) any later version. */
15 /* */
16 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19 /* License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24 /******************************************************************************/
25 
26 #include <cstdint>
27 #include <ctime>
28 #include <functional>
29 #include <string>
30 
31 class XrdNetAddrInfo;
32 class XrdSysError;
33 class XrdXrootdRedirPI;
34 
35 //------------------------------------------------------------------------------
57 //------------------------------------------------------------------------------
58 
60 {
61 public:
62 
63  //----------------------------------------------------------------------------
71  //----------------------------------------------------------------------------
72 
73  enum class Outcome { Unchanged, Replaced, Error };
74 
75  //----------------------------------------------------------------------------
89  //----------------------------------------------------------------------------
90 
91  static void Init(XrdXrootdRedirPI *pi, XrdSysError *eDest, int ipHold);
92 
93  //----------------------------------------------------------------------------
95  //----------------------------------------------------------------------------
96 
97  static bool IsActive();
98 
99  //----------------------------------------------------------------------------
145  //----------------------------------------------------------------------------
146 
147  static Outcome Redirect(const char *trg, int &port,
148  XrdNetAddrInfo &clientAddr,
149  std::string &outTarget, std::string &errMsg);
150 
151  //----------------------------------------------------------------------------
169  //----------------------------------------------------------------------------
170 
171  static bool ParseURL(const char *url, std::string &urlHead,
172  std::string &host, std::string &port,
173  std::string &urlTail);
174 
175  //----------------------------------------------------------------------------
192  //----------------------------------------------------------------------------
193  static void SetClockForTesting(std::function<time_t()> nowFn);
194 
195 private:
196 
197  XrdXrootdRedirHelper() = delete;
198  ~XrdXrootdRedirHelper() = delete;
199 };
200 
201 #endif
XrdSysError eDest(0, "HttpMon")
static Outcome Redirect(const char *trg, int &port, XrdNetAddrInfo &clientAddr, std::string &outTarget, std::string &errMsg)
static void Init(XrdXrootdRedirPI *pi, XrdSysError *eDest, int ipHold)
static bool ParseURL(const char *url, std::string &urlHead, std::string &host, std::string &port, std::string &urlTail)
static void SetClockForTesting(std::function< time_t()> nowFn)