Пример #1
0
        void add_point( std::string const &name )
        {
            auto info = utilities::get_endpoint_info( name );
            if( !info.is_ip( ) ) {
                LOGERR << "Endpoint format'" << name << "' is not valid";
                return;
            }

            try {

                auto addr = bip::address::from_string( info.addpess );

                bip::udp::endpoint listen_ep (
                            bip::address::from_string( addr.is_v6( )
                                                        ? any_ipv6
                                                        : any_ipv4 ),
                            info.service );

                LOGINF << "Adding endpoint '" << name << "'; "
                       << ( addr.is_v6( ) ? "ipv6" : "ipv4" )
                       << "; port: " << info.service;

                auto pinfo = std::make_shared<point_info>
                                ( app_->get_io_service( ), 256 );

                pinfo->sock.open( addr.is_v6( )
                                  ? bip::udp::v6( )
                                  : bip::udp::v4( ) );

                pinfo->sock.set_option( mcast_socket::reuse_address(true) );
                pinfo->sock.set_option( bip::multicast::join_group( addr ) );
                pinfo->sock.bind( listen_ep );
                {
                    std::lock_guard<std::mutex> l(points_lock_);
                    points_[name] = pinfo;
                }
                LOGDBG << "Store endpoint " << name << ". Ok";
            } catch( const std::exception &ex ) {
                LOGERR << "Add endpoint '" << name
                       << "' failed: " << ex.what( );
            }
        }
Пример #2
0
		std::string to_string() const
		{
			char Dest[46];
			if(is_v4())
				_inet_ntop(AF_INET, (void*)&ip_[0], Dest, 46);
			else if(is_v6())
				_inet_ntop(AF_INET6, (void*)&ip_[0], Dest, 46);
			else
				Dest[0] = 0;
			return Dest;
		}
Пример #3
0
		address_v6(const address& other) : address(other) {TORRENT_ASSERT(is_v6());}
Пример #4
0
		const address& to_v6() const	{TORRENT_ASSERT(is_v6()); return *this;}