示例#1
0
文件: oblob2.cpp 项目: mecirt/7k2
void Blob2D::fill_area(short x1, short y1, short x2, short y2, unsigned char color,
	int autoExtend)
{
	if( autoExtend )
	{
		extend_to(x1, y1, x2, y2);
	}
	else
	{
		// adjust x1, y1, x2 ,y2
		if( x1 < left_edge )
			x1 = left_edge;
		if( x2 >= left_edge+width )
			x2 = left_edge+width-1;
		if( y1 < top_edge )
			y1 = top_edge;
		if( y2 >= top_edge+height )
			y2 = top_edge+height-1;

		if( x2 < x1 || y2 < y1 )
			return;
	}

	int y = y1;
	unsigned char *dest = ptr->get_ptr( x1 - left_edge, y - top_edge );
	for( ; y <= y2; ++y, dest += width )
		memset(dest, color, x2-x1+1);
}
示例#2
0
文件: main.cpp 项目: wbenny/mini-tor
    void
    extend_to(
      const mini::string_ref onion_router_name
      )
    {
      mini::tor::onion_router* router = _consensus.get_onion_router_by_name(onion_router_name);

      if (router)
      {
        extend_to(router);
      }
    }
示例#3
0
    mini::string
    http_get(
      const mini::string_ref url
      )
    {
      mini::tor::tor_stream* stream = nullptr;
      mini::string result;

      mini::string url_string = url;

      mini_info("tor_client::http_get() fetching [%s]", url_string.get_buffer());
      if (url_string.starts_with("http://"))
      {
        url_string = url_string.substring(7);
      }

      if (url_string.contains("/") == false)
      {
        url_string += "/";
      }

      mini::string_collection url_parts = url_string.split("/", 1);
      mini::string host = url_parts[0];
      mini::string path = url_parts[1];
      uint16_t port = 80;

      if (host.ends_with(".onion"))
      {
        mini::string onion = host.substring(0, host.get_size() - 6);

        stream = _circuit->create_onion_stream(onion, port);
      }
      else
      {
        extend_to("colocall321");

        stream = _circuit->create_stream(host, port);
      }

      mini::string req = "GET " + path + " HTTP/1.0\r\nHost: " + host + "\r\n\r\n";
      stream->write(req.get_buffer(), req.get_size());

      mini::io::stream_reader sr(*stream);
      result = sr.read_string_to_end();

      delete stream;

      return result;
    }
示例#4
0
文件: oblob2.cpp 项目: mecirt/7k2
unsigned char *Blob2D::p(short x, short y, int autoExtend)
{
	if( autoExtend )
	{
		extend_to(x, y);
	}
	else
	{
		if( x < left_edge || x >= left_edge+width
			|| y < top_edge || y >= top_edge+height )
			return NULL;
	}

	return ptr->get_ptr(x-left_edge, y-top_edge);
}
示例#5
0
文件: main.cpp 项目: wbenny/mini-tor
    void
    extend_to_random(
      mini::tor::onion_router::status_flags flags,
      mini::collections::list<uint16_t> or_ports = {}
      )
    {
      auto routers = _consensus.get_onion_routers_by_criteria({
        {}, or_ports, _forbidden_onion_routers, flags
      });

      auto random_router = routers[mini::crypto::random_device.get_random(routers.get_size())];

      if (random_router)
      {
        _forbidden_onion_routers.add(random_router);
        extend_to(random_router);
      }
    }