Skip to content

Instantly share code, notes, and snippets.

🌴
Working from home

Adi Roiban adiroiban

🌴
Working from home
Block or report user

Report or block adiroiban

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@adiroiban
adiroiban / twisted_proxy_connect.py
Last active Oct 10, 2017
Twisted HTTP Connect Proxy
View twisted_proxy_connect.py
"""
Based on the code from Scrapy
BSD-3-Clause
"""
from __future__ import absolute_import, unicode_literals
import re
from urlparse import urlparse
from twisted.internet import defer
@adiroiban
adiroiban / ssl_sni_client.py
Created Oct 6, 2017
Simple test for pyOpenSSL with SNI
View ssl_sni_client.py
# Copyright (C) Jean-Paul Calderone
# See LICENSE for details.
from sys import argv, stdout
from socket import socket
from OpenSSL.SSL import TLSv1_METHOD, Context, Connection
def test_ssl_client_sni():
@adiroiban
adiroiban / ldaptor_as_ad_server.py
Created Sep 22, 2017
ldaptor LDAP server faking AD UPN BIND
View ldaptor_as_ad_server.py
"""
An ldaptor LDAP server which can authenticate based on UPN, as AD does.
The LDAP entry needs to have the `userPrincipalName` attribute set.
"""
from __future__ import absolute_import
from ldaptor import interfaces
from ldaptor.protocols import pureldap
from ldaptor.protocols.ldap import distinguishedname, ldaperrors
View bashrc
# based on the prompt from
# http://www.gilesorr.com/bashprompt/prompts/twtty.html
function prompt_command {
TERMWIDTH=${COLUMNS}
# Calculate the width of the prompt:
hostnam=$(echo -n $HOSTNAME | sed -e "s/[\.].*//")
# "whoami" and "pwd" include a trailing newline
#usernam=$(whoami)
@adiroiban
adiroiban / crl_cdp_validator.py
Last active May 19, 2017
pyopenssl SSLContext.set_verify callback for CRL / CDP validation
View crl_cdp_validator.py
class CRLValidator(object):
"""
Helper for validating certificates against CRL.
For now it only support a single CRL signed by a single CA.
It provides the `CRLValidator.validate(certificate)` method which can be
used as a callback for `SSLContext.set_verify`.
"""
_random = random
@adiroiban
adiroiban / example run
Last active Jan 31, 2019
Persistent pool not closed in Twisted
View example run
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
>>> import cryptography
>>> import OpenSSL
>>> cryptography.__version__
'1.7.2'
>>> OpenSSL.__version__
'16.2.0'
>>>
@adiroiban
adiroiban / form.py
Last active Aug 12, 2016
Twisted support for parsing multipart/form-data POST requests
View form.py
# Copyright (c) 2014 Adi Roiban.
# See LICENSE for details.
"""
Code for handling data submitted via HTTP form.
We should try to keep this code independent of Chevah project as we plan
to send it upstream in Twisted.
"""
from StringIO import StringIO
@adiroiban
adiroiban / endpoint_client_server.py
Last active Aug 11, 2016
Client TLS transport connected state out of sync
View endpoint_client_server.py
#
# Script to demonstrate the Client.transport.connected state
#
from twisted.internet.protocol import Protocol
from twisted.internet.protocol import Factory
from twisted.internet.endpoints import SSL4ServerEndpoint, TCP4ServerEndpoint
from twisted.internet.endpoints import (
SSL4ClientEndpoint, TCP4ClientEndpoint, connectProtocol)
from twisted.internet import reactor
from twisted.internet.ssl import PrivateCertificate, ClientContextFactory
@adiroiban
adiroiban / twisted.diff
Created Jul 19, 2016
pydoctor for twisted no fetch
View twisted.diff
diff --git twisted/python/_pydoctor.py twisted/python/_pydoctor.py
index 76a5458..4d064b4 100644
--- twisted/python/_pydoctor.py
+++ twisted/python/_pydoctor.py
@@ -60,6 +60,13 @@ class TwistedSphinxInventory(SphinxInventory):
# as an exceptional case.
# We get the base URL from IInterface which is assume that is
# always and already well defined in the Sphinx index.
+ link = self._links.get('zope.interface.interfaces.IInterface')
+
You can’t perform that action at this time.