[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#139710: first version of https support available



On Thu, 4 Apr 2002, Jason Gunthorpe wrote:

>
> On Thu, 4 Apr 2002, Tomas Pospisek wrote:
>
> > Yes it would be nice if it was that easy. The problem is this:
> > If I subclass CircleBuf (say CircleBufSSL), then everbody who has a
> > CircleBuf member has to replace it by the CircleBuffSSL version along with
>
> Er.
>
> That is not really how subclassing is ment to work at all, the entire
> point is that everyone will just keep using a normal CircleBuf and
> magically get redirected to a SSL verison.
>
> This does mean changing all CircleBuf instances to a pointer and using new
> to allocate the correct varient.
>
> So you would probably simply write this:
>
> class CircleBufSSL : public CircleBuf
> {
>    SSL *ctx;
>    public:
>
>    virtual bool Read(int Fd);
>    virtual bool Write(int Fd);
>
>    CircleBufSSL(SSL *ctx);
> }
>
> [..]
>    if (https)
>    {
>        In = new CircleBufSSL(ssl);
>        Out = new CircleBufSSL(ssl);
>    }
>    else
>    {
>        In = new CircleBuf();
>        Out = new CircleBuf();
>    }

Which means that finally the ifdefs will be transformed in ifs and ww'll
have f.ex. in HttpMethod::Loop:

	// Connect to the host
	if(Server->Open() == false)
	{
		[...]
	}
	if (https && ConnectSSL(ServerFd,&ctx) == false) {
		[...]
	}

And then ConnectSSL would look like:

bool ConnectSSL(int &Fd, SSL **Ssl)
{
#ifnded WITH_SSL
	clog("Https method unavailable - APT was not linked against openssl");
	return false;
#else
	[... ssl-connect ...]
#endif
}

Am I interpreting your taste correctly?

> Templates are not a solution to this problem, the code above is by no
> means correct or complete. There are several other little details, like
> the Read(int fd) stuff is kind of a misnomer since the class is no longer
> symetric, but that's an easy change..
>
> > > Making 'ProxyStr' a string is silly, it is never assigned to anything but
> > > a constant.
>
> > Well, I have tried out the alternatives: char * and just replacing http
> > everywhere by:
>
> Why would you do that? ProxyStr is only used as an argument to getenv,
> if you make it a 'const char *' and take out the .c_str() then you have
> done all I asked.

Ack, works, thanks a lot for the hint!
*t

-----------------------------------------------------------------------
     Tomas Pospisek
     sourcepole    -   Linux & Open Source Solutions
     http://sourcepole.com
     Elestastrasse 18,  7310 Bad Ragaz,  Switzerland
     Tel:+41 (81) 330 77 13,  Fax:+41 (81) 330 77 12
------------------------------------------------------------------------


-- 
To UNSUBSCRIBE, email to deity-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: