Pass extra information to _handle_cert_request #26
39
av98.py
39
av98.py
|
@ -484,7 +484,7 @@ you'll be able to transparently follow links to Gopherspace!""")
|
|||
|
||||
# Client cert
|
||||
elif status.startswith("6"):
|
||||
self._handle_cert_request(meta)
|
||||
self._handle_cert_request(meta, status, gi.host)
|
||||
return self._fetch_over_network(gi)
|
||||
|
||||
# Invalid status
|
||||
|
@ -700,7 +700,7 @@ you'll be able to transparently follow links to Gopherspace!""")
|
|||
for _, filename in self.cache.values():
|
||||
assert os.path.isfile(filename)
|
||||
|
||||
def _handle_cert_request(self, meta):
|
||||
def _handle_cert_request(self, meta, status, host):
|
||||
|
||||
# Don't do client cert stuff in restricted mode, as in principle
|
||||
# it could be used to fill up the disk by creating a whole lot of
|
||||
|
@ -719,7 +719,7 @@ you'll be able to transparently follow links to Gopherspace!""")
|
|||
print("The server did not accept your certificate.")
|
||||
print("You may need to e.g. coordinate with the admin to get your certificate fingerprint whitelisted.")
|
||||
else:
|
||||
print("The site {} is requesting a client certificate.".format(gi.host))
|
||||
print("The site {} is requesting a client certificate.".format(host))
|
||||
print("This will allow the site to recognise you across requests.")
|
||||
|
||||
# Give the user choices
|
||||
|
@ -727,8 +727,8 @@ you'll be able to transparently follow links to Gopherspace!""")
|
|||
print("1. Give up.")
|
||||
print("2. Generate a new transient certificate.")
|
||||
print("3. Generate a new persistent certificate.")
|
||||
print("4. Load a previously generated persistent.")
|
||||
print("5. Load certificate from an external file.")
|
||||
print("4. Load a previously generated certificate.")
|
||||
print("5. Load a certificate from an external file.")
|
||||
choice = input("> ").strip()
|
||||
if choice == "2":
|
||||
self._generate_transient_cert_cert()
|
||||
|
@ -913,13 +913,13 @@ you'll be able to transparently follow links to Gopherspace!""")
|
|||
initial_indent = "> ", subsequent_indent="> ") + "\n")
|
||||
elif line.startswith("###"):
|
||||
line = line[3:].lstrip("\t ")
|
||||
tmpf.write("\x1b[4m" + line + "\x1b[0m""\n")
|
||||
tmpf.write("\x1b[4m" + textwrap.fill(line, self.options["width"]) + "\x1b[0m""\n")
|
||||
elif line.startswith("##"):
|
||||
line = line[2:].lstrip("\t ")
|
||||
tmpf.write("\x1b[1m" + line + "\x1b[0m""\n")
|
||||
tmpf.write("\x1b[1m" + textwrap.fill(line, self.options["width"]) + "\x1b[0m""\n")
|
||||
elif line.startswith("#"):
|
||||
line = line[1:].lstrip("\t ")
|
||||
tmpf.write("\x1b[1m\x1b[4m" + line + "\x1b[0m""\n")
|
||||
tmpf.write("\x1b[1m\x1b[4m" + textwrap.fill(line, self.options["width"]) + "\x1b[0m""\n")
|
||||
else:
|
||||
tmpf.write(textwrap.fill(line, self.options["width"]) + "\n")
|
||||
tmpf.close()
|
||||
|
@ -935,6 +935,8 @@ you'll be able to transparently follow links to Gopherspace!""")
|
|||
def _format_geminiitem(self, index, gi, url=False):
|
||||
protocol = "" if gi.scheme == "gemini" else " %s" % gi.scheme
|
||||
line = "[%d%s] %s" % (index, protocol, gi.name or gi.url)
|
||||
if gi.name:
|
||||
line = textwrap.fill(line, self.options["width"], subsequent_indent=" ")
|
||||
if gi.name and url:
|
||||
line += " (%s)" % gi.url
|
||||
return line
|
||||
|
@ -1480,8 +1482,25 @@ Use 'ls -l' to see URLs."""
|
|||
|
||||
@needs_gi
|
||||
def do_url(self, *args):
|
||||
"""Print URL of most recently visited item."""
|
||||
print(self.gi.url)
|
||||
"""Print the URL of an item.
|
||||
'url' prints the URL of the most recently visited item.
|
||||
'url n' prints the URL of item n."""
|
||||
# If no argument print current URL
|
||||
if args[0] == '':
|
||||
print(self.gi.url)
|
||||
return
|
||||
# If there is a valid integer argument print url of that item.
|
||||
try:
|
||||
n = int(args[0])
|
||||
except ValueError:
|
||||
print("Invalid item number.")
|
||||
return
|
||||
try:
|
||||
gi = self.lookup[n-1]
|
||||
except IndexError:
|
||||
print ("Index too high!")
|
||||
return
|
||||
print(gi.url)
|
||||
|
||||
### Bookmarking stuff
|
||||
@restricted
|
||||
|
|
Loading…
Reference in New Issue