summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-02 10:33:49 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-02 10:33:49 +0000
commit21347e95fd0f3186e6e95d09193a687ebff68ad6 (patch)
tree505da58d79c251b9606783a4e6b6390a7db80b92 /src
parenta54cfebb0434574f91acdcee07b89ea9f682d272 (diff)
Comment ServernameResolver class
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4635 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_spanningtree.cpp64
1 files changed, 41 insertions, 23 deletions
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index c91926d98..73d054b24 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -3065,33 +3065,51 @@ class TreeSocket : public InspSocket
}
};
+/** This class is used to resolve server hostnames during /connect and autoconnect.
+ * As of 1.1, the resolver system is seperated out from InspSocket, so we must do this
+ * resolver step first ourselves if we need it. This is totally nonblocking, and will
+ * callback to OnLookupComplete or OnError when completed. Once it has completed we
+ * will have an IP address which we can then use to continue our connection.
+ */
class ServernameResolver : public Resolver
{
private:
- Link MyLink;
+ /** A copy of the Link tag info for what we're connecting to.
+ * We take a copy, rather than using a pointer, just in case the
+ * admin takes the tag away and rehashes while the domain is resolving.
+ */
+ Link MyLink;
public:
- ServernameResolver(const std::string &hostname, Link x) : Resolver(hostname, true), MyLink(x)
- {
- }
-
- void OnLookupComplete(const std::string &result)
- {
- TreeSocket* newsocket = new TreeSocket(result,MyLink.Port,false,10,MyLink.Name.c_str());
- if (newsocket->GetFd() > -1)
- {
- Srv->AddSocket(newsocket);
- }
- else
- {
- WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno));
- delete newsocket;
- }
- }
-
- void OnError(ResolverError e)
- {
- WriteOpers("*** CONNECT: Error connecting \002%s\002: Unable to resolve hostname.",MyLink.Name.c_str());
- }
+ ServernameResolver(const std::string &hostname, Link x) : Resolver(hostname, true), MyLink(x)
+ {
+ /* Nothing in here, folks */
+ }
+
+ void OnLookupComplete(const std::string &result)
+ {
+ /* Initiate the connection, now that we have an IP to use.
+ * Passing a hostname directly to InspSocket causes it to
+ * just bail and set its FD to -1.
+ */
+ TreeSocket* newsocket = new TreeSocket(result,MyLink.Port,false,10,MyLink.Name.c_str());
+ if (newsocket->GetFd() > -1)
+ {
+ /* We're all OK */
+ Srv->AddSocket(newsocket);
+ }
+ else
+ {
+ /* Something barfed, show the opers */
+ WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno));
+ delete newsocket;
+ }
+ }
+
+ void OnError(ResolverError e)
+ {
+ /* Ooops! */
+ WriteOpers("*** CONNECT: Error connecting \002%s\002: Unable to resolve hostname.",MyLink.Name.c_str());
+ }
};