java中的接口是类吗
374
2022-09-07
Panda_Cloud_v1.2 源代码开源(panda云下载)
大家好,我经过了认真的考虑,决定将我自己的局域网文件储存项目熊猫云(英文名 Panda Cloud) 的主要代码开源。
现我已开发至 1.2 版本,可能还有一些缺点,我后面会修改,也欢迎大家提出。
一定要注意!!我的项目未经允许不得转载!!!仅供学习和参考!!!
贴上原来的仓库地址:我是传送门。
我的项目的内部版本目录树:
D:.│ Application_Program.zip│ README.md│├─Encryption_Client│ main.py│ URL_Generation_Tool.py│├─Encryption_Server│ │ BITURL│ │ USE.py│ ││ ├─files│ └─panda│ │ db.sqlite3│ │ manage.py│ ││ └─panda│ │ asgi.py│ │ settings.py│ │ urls.py│ │ wsgi.py│ │ __init__.py│ ││ └─__pycache__│ settings.cpython-36.pyc│ urls.cpython-36.pyc│ wsgi.cpython-36.pyc│ __init__.cpython-36.pyc│├─Original_Client│ │ main.py│ │ URL_Generation_Tool.py│ ││ └─__pycache__│ URL_Generation_Tool.cpython-36.pyc│└─Original_Server │ BITURL │ USE.py │ ├─files └─panda │ db.sqlite3 │ manage.py │ └─panda │ asgi.py │ settings.py │ urls.py │ wsgi.py │ __init__.py │ └─__pycache__ settings.cpython-36.pyc urls.cpython-36.pyc wsgi.cpython-36.pyc __init__.cpython-36.pyc
详细使用文档,请看项目仓库,如果看不懂,请百度翻译(我为了显得高大上整了个全英文……)
客户端源代码
USE.py
# Use this program to open Panda Cloud.# Copyright 2022 by PanDaoxi.All rights reserved.# E-mail: 2060642520@qq.com# See Date: 2022-3-20 Time: 13:05# Import packagefrom os import name, systemfrom time import strftimefrom socket import socket, AF_INET, SOCK_DGRAM# Get LAN IP addressdef getIP(): try: sock = socket(AF_INET, SOCK_DGRAM) sock.connect(("8.8.8.8", 80)) ip = sock.getsockname()[0] finally: sock.close() return ip# Create serverdef main(): ip = getIP() port = strftime("%Y") setIP = ip + ":" + port print("Get IP address: number: %s (Current year)" % (ip, port)) print("Creating server, please wait...\n\n") system(r"python .\panda\manage.py runserver %s" % setIP)# Run the current programif __name__ == "__main__" and name == "nt": main() input("")else: print( "Your PC can't run this program because:\n(1) Non autonomous operation procedures;\n(2) You are not using a Windows operating system.\nIf it cannot be solved, please contact the developer." ) input("")
panda\panda\urls.py
核心服务器软件。源码如下:
# This is Panda Cloud internal code. Don't modify it.# Copyright 2022 by PanDaoxi.All rights reserved.from django.shortcuts import HttpResponsefrom django.urls import pathfrom json import dumpsfrom base64 import b64encode, b64decode ,a85encode ,a85decodefrom os import walk, mkdirfrom os.path import exists, joinfrom colorama import *from hashlib import md5from random import randint# The encryption algorithm made by the author.marks = {}string = '0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz`~@#$%^&*()_+{}|\/{}[]<>?:;"\'=+-.,!'# Generate character mapping dictionaryfor i in range(0,len(string)): if i <= 9: marks['0' + str(i)] = string[i] else: marks[str(i)] = string[i]# Encryption algorithm program - the first generation of DX algorithm.class __Daoxi(): def __init__(self): self.content = 'Daoxi Encode'.encode() self.interval_mark = '-' self.ec = 'UTF-8' self.marks = marks # Encryption program. def encode(self): try: text = a85encode(self.content).decode(self.ec) letters = [] for i in text: letters.append(list(marks.keys())[list(marks.values()).index(i)]) return ['OKAY',self.interval_mark.join(letters)] except Exception as e: return ['ERROR',e] # Decryption program. def decode(self): try: text = self.content.split(self.interval_mark) letters = [] for i in text: letters.append(marks[i]) result = ''.join(letters) return ['OKAY',a85decode(result.encode(self.ec))] except Exception as e: return ['ERROR',e]# Generate objects.daoxi = __Daoxi()# ColorAMA Console paletteinit()class Colors: def __init__(self): pass def red(self, s): return Fore.RED + s + Fore.RESET def green(self, s): return Fore.GREEN + s + Fore.RESET def yellow(self, s): return Fore.YELLOW + s + Fore.RESET def blue(self, s): return Fore.BLUE + s + Fore.RESET def magenta(self, s): return Fore.MAGENTA + s + Fore.RESET def cyan(self, s): return Fore.CYAN + s + Fore.RESET def white(self, s): return Fore.WHITE + s + Fore.RESET def black(self, s): return Fore.BLACK# Generate objects.color = Colors()# Create MD5 textsgetHash = lambda s: md5(s).hexdigest()# Check whether the file is normal.if not exists("files"): mkdir("files")if not exists("BITURL"): with open("BITURL", "w", encoding="utf-8") as f: f.write("")# When the user accesses IP:PORT/def main(request): # Output the text print(color.magenta("A user visited the home page.")) # Return the HTML code of the home page. return HttpResponse("
客户端
# Import package.from requests import post, getfrom tkinter import Tkfrom tkinter.filedialog import *from os import remove, environ, name, systemfrom os.path import exists, splitextfrom time import strftimefrom easygui import *from socket import socket, AF_INET, SOCK_DGRAMfrom base64 import b64encode, b64decodefrom sys import exitfrom re import compilefrom webbrowser import open as openW# Declare the settings of variables and packages that the program depends on.title = "Panda Cloud (Client)"hide = Tk()hide.withdraw()desktop = environ["USERPROFILE"] + "\\Desktop"# Declare the settings of variables and packages that the program depends on.def getIP(): try: sock = socket(AF_INET, SOCK_DGRAM) sock.connect(("8.8.8.8", 80)) ip = sock.getsockname()[0] finally: sock.close() return ip# First, use file search to obtain the server. If not, use the LAN IP of the current computer.if exists("url"): with open("url", "r", encoding="utf-8") as f: ip = f.read()else: ip = "% (getIP(), strftime("%Y"))# File upload functiondef upload(): upd = askopenfilename(title=title, filetypes=[("All Files", "*.*")]) with open(upd, "rb") as f: temp = b64encode(f.read()).decode() up = upd.split("/") data = { "name": up[len(up) - 1], "text": temp, } res1 = post(ip + "upload", data=data).json()["state"] if res1 == "okay": msgbox("File upload succeeded.", title)# File download functiondef download(): res1 = get(ip + "visitall").json()["files"] file_list = b64decode(res1.encode()).decode().split("/") if res1 != "": cho = choicebox("Please select the file to download.", title, choices=file_list) res2 = get(ip + "download?file=%s" % cho).json() fileText = b64decode(res2["file"].encode()) types = splitext(cho)[1] dow = asksaveasfilename( title=title, filetypes=[("All Files", types)], initialfile=cho, initialdir=desktop, ) with open(dow, "wb") as f: f.write(fileText) msgbox("File download succeeded.", title) else: msgbox("You haven't uploaded any files yet. Please upload one first.", title)# Short URL functiondef biturl(): url = enterbox("Enter the original URL you need to generate a short URL:", title) comp = r"( if not compile(url): msgbox("The URL you entered is incorrect. Please re-enter it.", title) exit() res1 = get( ip + "biturl", params={ "url": url, }, ).json() if res1["text"] == "okay": bitu = ip + res1["biturl"] msgbox( "Your short URL was generated successfully! You can visit the following website.\n\nOriginal website: %s\nShortened URL: %s" % (url, bitu), title, )# Main function (task assignment function)def main(): t = ["File Upload", "File Download", "Short URL", "About", "Switch Server", "Exit"] cho = buttonbox("Please select the service you need.\nServer: %s" % ip, title, t) if cho == t[0]: upload() elif cho == t[1]: download() elif cho == t[2]: biturl() elif cho == t[3]: textbox( "Here are some information about us:", title, text="About us:\nBlog: email: 2060642520@qq.com\nWechat: pandaoxi2021\nQQ:3377063617\n\nWelcome to this program! This program is designed to help all users in the LAN carry out network transmission, and the main functions are as follows:\n1. Server cloud storage;\n2. Upload and download files quickly (without speed limit);\n3. Shorten the website quickly to make access more convenient;\n4. The program runs quickly and supports multiple operating systems;\n5. Encrypted file transmission.\nIf you have any related questions, you can use any of the contact information mentioned above to contact us for reporting; If an error is found during the operation of the program, please report it to the developer. thank!", ) elif cho == t[4]: if name == "nt": temp = get(' with open('function.exe','wb') as f: f.write(temp.content) system('call function.exe') else: openW(" msgbox("You can use this program to modify the IP address of the program.",title) exit() else: exit()# Judge operating conditionsif __name__ == "__main__": try: while True: main() except Exception as e: msgbox( "A fatal error has occurred in the program, so the program cannot run. Please send this message to the developer: %s" % e, title, )hide.mainloop()
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~