Browse Source

added x509 generator

galo 1 year ago
parent
commit
0180eceb54
3 changed files with 267 additions and 19 deletions
  1. 27 1
      Login.gd
  2. 207 18
      main.tscn
  3. 33 0
      x509gen.gd

+ 27 - 1
Login.gd

@@ -2,18 +2,44 @@ extends Node
 
 var client = preload('res://Client.tscn')
 var server = preload('res://Server.tscn')
+signal login_confimed
+var login_await = true
+
+func _ready():
+	for i in get_children():
+		i.hide()
+	$directconnect.show()
 
 func _on_Button_button_down():
+	$directconnect.hide()
+	$loginscreen.show()
+	if login_await: yield(self,'login_confimed')
+	$loginscreen.hide()
 	var client2 = client.instance()
 	var ip = $directconnect/VBoxContainer/HBoxContainer/LineEdit2.get_text()
 	var port = $directconnect/VBoxContainer/HBoxContainer/LineEdit.get_text()
 	client2.ip = ip
 	client2.port = int(port)
 	get_parent().add_child(client2)
-	$directconnect.hide()
 	pass # Replace with function body.
 
 func _on_Button2_button_down():
 	var server2 = server.instance()
 	get_parent().add_child(server2)
 	pass # Replace with function body.
+
+func _on_CheckButton_toggled(button_pressed):
+	login_await = button_pressed
+	pass # Replace with function body.
+
+func _on_register_button_down():
+	$loginscreen.hide()
+	$register.show()
+	pass # Replace with function body.
+
+func _on_login2_button_down():
+	$loginscreen.show()
+	$register.hide()
+	pass # Replace with function body.
+
+

+ 207 - 18
main.tscn

@@ -1,8 +1,9 @@
-[gd_scene load_steps=12 format=2]
+[gd_scene load_steps=13 format=2]
 
 [ext_resource path="res://Login.gd" type="Script" id=1]
 [ext_resource path="res://envarg.gd" type="Script" id=2]
 [ext_resource path="res://Database.gd" type="Script" id=3]
+[ext_resource path="res://x509gen.gd" type="Script" id=4]
 [ext_resource path="res://art/Untitledcxz.png" type="Texture" id=10]
 [ext_resource path="res://Textures.gd" type="Script" id=11]
 [ext_resource path="res://Camera2D.gd" type="Script" id=13]
@@ -45,6 +46,7 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin1"]
 modulate = Color( 0, 0.811765, 1, 1 )
 frames = SubResource( 5 )
+frame = 1
 playing = true
 offset = Vector2( 32, 32 )
 
@@ -70,7 +72,7 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin3"]
 modulate = Color( 1, 0, 0, 1 )
 frames = SubResource( 5 )
-frame = 3
+frame = 1
 speed_scale = 1.2
 playing = true
 offset = Vector2( 32, 32 )
@@ -84,6 +86,7 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin4"]
 modulate = Color( 1, 0, 0.984314, 1 )
 frames = SubResource( 5 )
+frame = 3
 speed_scale = 0.9
 playing = true
 offset = Vector2( 32, 32 )
@@ -91,27 +94,27 @@ offset = Vector2( 32, 32 )
 [node name="Database" type="Node" parent="."]
 script = ExtResource( 3 )
 
-[node name="Login" type="Node" parent="."]
+[node name="LoginUI" type="Node" parent="."]
 script = ExtResource( 1 )
 
-[node name="directconnect" type="Control" parent="Login"]
+[node name="directconnect" type="Control" parent="LoginUI"]
 anchor_right = 1.0
 anchor_bottom = 1.0
 margin_left = 180.0
 margin_right = -180.0
 
-[node name="VBoxContainer" type="VBoxContainer" parent="Login/directconnect"]
+[node name="VBoxContainer" type="VBoxContainer" parent="LoginUI/directconnect"]
 anchor_right = 1.0
 anchor_bottom = 1.0
 alignment = 1
 
-[node name="HBoxContainer" type="HBoxContainer" parent="Login/directconnect/VBoxContainer"]
-margin_top = 144.0
+[node name="HBoxContainer" type="HBoxContainer" parent="LoginUI/directconnect/VBoxContainer"]
+margin_top = 110.0
 margin_right = 280.0
-margin_bottom = 168.0
+margin_bottom = 134.0
 alignment = 1
 
-[node name="LineEdit2" type="LineEdit" parent="Login/directconnect/VBoxContainer/HBoxContainer"]
+[node name="LineEdit2" type="LineEdit" parent="LoginUI/directconnect/VBoxContainer/HBoxContainer"]
 margin_right = 218.0
 margin_bottom = 24.0
 size_flags_horizontal = 3
@@ -121,7 +124,7 @@ align = 1
 expand_to_text_length = true
 placeholder_text = "IP Adress"
 
-[node name="LineEdit" type="LineEdit" parent="Login/directconnect/VBoxContainer/HBoxContainer"]
+[node name="LineEdit" type="LineEdit" parent="LoginUI/directconnect/VBoxContainer/HBoxContainer"]
 margin_left = 222.0
 margin_right = 280.0
 margin_bottom = 24.0
@@ -129,18 +132,197 @@ text = "8081"
 align = 1
 placeholder_text = "Port"
 
-[node name="Button" type="Button" parent="Login/directconnect/VBoxContainer"]
-margin_top = 172.0
+[node name="Button" type="Button" parent="LoginUI/directconnect/VBoxContainer"]
+margin_top = 138.0
 margin_right = 280.0
-margin_bottom = 192.0
+margin_bottom = 158.0
 text = "connnect"
 
-[node name="Button2" type="Button" parent="Login/directconnect/VBoxContainer"]
-margin_top = 196.0
+[node name="Button2" type="Button" parent="LoginUI/directconnect/VBoxContainer"]
+margin_top = 162.0
 margin_right = 280.0
-margin_bottom = 216.0
+margin_bottom = 182.0
 text = "create server"
 
+[node name="x509" type="Button" parent="LoginUI/directconnect/VBoxContainer"]
+margin_top = 186.0
+margin_right = 280.0
+margin_bottom = 206.0
+text = "x509"
+
+[node name="CheckButton" type="CheckButton" parent="LoginUI/directconnect/VBoxContainer"]
+margin_top = 210.0
+margin_right = 280.0
+margin_bottom = 250.0
+pressed = true
+text = "login"
+
+[node name="loginscreen" type="Control" parent="LoginUI"]
+visible = false
+anchor_right = 1.0
+anchor_bottom = 1.0
+margin_left = 180.0
+margin_right = -180.0
+
+[node name="VBoxContainer" type="VBoxContainer" parent="LoginUI/loginscreen"]
+anchor_right = 1.0
+anchor_bottom = 1.0
+alignment = 1
+
+[node name="HBoxContainer" type="HBoxContainer" parent="LoginUI/loginscreen/VBoxContainer"]
+margin_top = 142.0
+margin_right = 287.0
+margin_bottom = 166.0
+alignment = 1
+
+[node name="LineEdit2" type="LineEdit" parent="LoginUI/loginscreen/VBoxContainer/HBoxContainer"]
+margin_right = 287.0
+margin_bottom = 24.0
+size_flags_horizontal = 3
+size_flags_vertical = 3
+align = 1
+expand_to_text_length = true
+placeholder_text = "username"
+
+[node name="HBoxContainer2" type="HBoxContainer" parent="LoginUI/loginscreen/VBoxContainer"]
+margin_top = 170.0
+margin_right = 287.0
+margin_bottom = 194.0
+alignment = 1
+
+[node name="LineEdit2" type="LineEdit" parent="LoginUI/loginscreen/VBoxContainer/HBoxContainer2"]
+margin_right = 287.0
+margin_bottom = 24.0
+size_flags_horizontal = 3
+size_flags_vertical = 3
+align = 1
+expand_to_text_length = true
+placeholder_text = "password"
+
+[node name="HBoxContainer3" type="HBoxContainer" parent="LoginUI/loginscreen/VBoxContainer"]
+margin_top = 198.0
+margin_right = 287.0
+margin_bottom = 218.0
+alignment = 1
+
+[node name="login" type="Button" parent="LoginUI/loginscreen/VBoxContainer/HBoxContainer3"]
+margin_right = 43.0
+margin_bottom = 20.0
+text = "login"
+
+[node name="register" type="Button" parent="LoginUI/loginscreen/VBoxContainer/HBoxContainer3"]
+margin_left = 47.0
+margin_right = 111.0
+margin_bottom = 20.0
+text = "Register"
+
+[node name="recover" type="Button" parent="LoginUI/loginscreen/VBoxContainer/HBoxContainer3"]
+margin_left = 115.0
+margin_right = 242.0
+margin_bottom = 20.0
+text = "Recover Password"
+
+[node name="back" type="Button" parent="LoginUI/loginscreen/VBoxContainer/HBoxContainer3"]
+margin_left = 246.0
+margin_right = 287.0
+margin_bottom = 20.0
+text = "back"
+
+[node name="register" type="Control" parent="LoginUI"]
+visible = false
+anchor_right = 1.0
+anchor_bottom = 1.0
+margin_left = 180.0
+margin_right = -180.0
+
+[node name="VBoxContainer" type="VBoxContainer" parent="LoginUI/register"]
+anchor_right = 1.0
+anchor_bottom = 1.0
+alignment = 1
+
+[node name="HBoxContainer" type="HBoxContainer" parent="LoginUI/register/VBoxContainer"]
+margin_top = 114.0
+margin_right = 280.0
+margin_bottom = 138.0
+alignment = 1
+
+[node name="LineEdit2" type="LineEdit" parent="LoginUI/register/VBoxContainer/HBoxContainer"]
+margin_right = 280.0
+margin_bottom = 24.0
+size_flags_horizontal = 3
+size_flags_vertical = 3
+align = 1
+expand_to_text_length = true
+placeholder_text = "username"
+
+[node name="HBoxContainer2" type="HBoxContainer" parent="LoginUI/register/VBoxContainer"]
+margin_top = 142.0
+margin_right = 280.0
+margin_bottom = 166.0
+alignment = 1
+
+[node name="LineEdit2" type="LineEdit" parent="LoginUI/register/VBoxContainer/HBoxContainer2"]
+margin_right = 280.0
+margin_bottom = 24.0
+size_flags_horizontal = 3
+size_flags_vertical = 3
+align = 1
+expand_to_text_length = true
+placeholder_text = "password"
+
+[node name="HBoxContainer4" type="HBoxContainer" parent="LoginUI/register/VBoxContainer"]
+margin_top = 170.0
+margin_right = 280.0
+margin_bottom = 194.0
+alignment = 1
+
+[node name="LineEdit2" type="LineEdit" parent="LoginUI/register/VBoxContainer/HBoxContainer4"]
+margin_right = 280.0
+margin_bottom = 24.0
+size_flags_horizontal = 3
+size_flags_vertical = 3
+align = 1
+expand_to_text_length = true
+placeholder_text = "comfirm password"
+
+[node name="HBoxContainer5" type="HBoxContainer" parent="LoginUI/register/VBoxContainer"]
+margin_top = 198.0
+margin_right = 280.0
+margin_bottom = 222.0
+alignment = 1
+
+[node name="LineEdit2" type="LineEdit" parent="LoginUI/register/VBoxContainer/HBoxContainer5"]
+margin_right = 280.0
+margin_bottom = 24.0
+size_flags_horizontal = 3
+size_flags_vertical = 3
+align = 1
+expand_to_text_length = true
+placeholder_text = "email"
+
+[node name="HBoxContainer3" type="HBoxContainer" parent="LoginUI/register/VBoxContainer"]
+margin_top = 226.0
+margin_right = 280.0
+margin_bottom = 246.0
+alignment = 1
+
+[node name="login2" type="Button" parent="LoginUI/register/VBoxContainer/HBoxContainer3"]
+margin_left = 85.0
+margin_right = 149.0
+margin_bottom = 20.0
+text = "Login"
+
+[node name="Register2" type="Button" parent="LoginUI/register/VBoxContainer/HBoxContainer3"]
+margin_left = 85.0
+margin_right = 149.0
+margin_bottom = 20.0
+text = "Register"
+
+[node name="Label" type="Label" parent="LoginUI/register/VBoxContainer"]
+margin_right = 40.0
+margin_bottom = 14.0
+text = "status"
+
 [node name="Authority" type="Node" parent="."]
 
 [node name="Camera2D" type="Camera2D" parent="."]
@@ -151,5 +333,12 @@ script = ExtResource( 13 )
 [node name="envarg" type="Node" parent="."]
 script = ExtResource( 2 )
 
-[connection signal="button_down" from="Login/directconnect/VBoxContainer/Button" to="Login" method="_on_Button_button_down"]
-[connection signal="button_down" from="Login/directconnect/VBoxContainer/Button2" to="Login" method="_on_Button2_button_down"]
+[node name="x509gen" type="Node" parent="."]
+script = ExtResource( 4 )
+
+[connection signal="button_down" from="LoginUI/directconnect/VBoxContainer/Button" to="LoginUI" method="_on_Button_button_down"]
+[connection signal="button_down" from="LoginUI/directconnect/VBoxContainer/Button2" to="LoginUI" method="_on_Button2_button_down"]
+[connection signal="button_down" from="LoginUI/directconnect/VBoxContainer/x509" to="x509gen" method="_on_x509_button_down"]
+[connection signal="toggled" from="LoginUI/directconnect/VBoxContainer/CheckButton" to="LoginUI" method="_on_CheckButton_toggled"]
+[connection signal="button_down" from="LoginUI/loginscreen/VBoxContainer/HBoxContainer3/register" to="LoginUI" method="_on_register_button_down"]
+[connection signal="button_down" from="LoginUI/register/VBoxContainer/HBoxContainer3/login2" to="LoginUI" method="_on_login2_button_down"]

+ 33 - 0
x509gen.gd

@@ -0,0 +1,33 @@
+extends Node
+
+var x509_cert_filename = "x509_Certificate.crt"
+var x509_key_filename = "x509_Key.key"
+onready var x509_cert_path = "user://Certificate/" + x509_cert_filename
+onready var x509_key_path = "user://Certificate/" + x509_key_filename
+
+var CN = "MultiplayerProject"
+var O = "Galo"
+var C = "BR"
+var not_before = "20201023000000"
+var not_after = "20211022235900"
+
+func _on_x509_button_down():
+	var directory = Directory.new()
+	if directory.dir_exists("user://Certificate"):
+		pass
+	else:
+		directory.make_dir("user://Certificate")
+	CreateX509Cert()
+	print("Certificate Create")
+
+func CreateX509Cert():
+	print('generating cert')
+	var CNOC = "CN=" + CN + ",0=" + O + ",C=" + C
+	var crypto = Crypto.new()
+	var crypto_key = crypto.generate_rsa(4096)
+	var x509_cert = crypto.generate_self_signed_certificate(crypto_key, CNOC, not_before, not_after)
+	x509_cert.save(x509_cert_path)
+	crypto_key.save(x509_key_path)
+	print('finished making cert')
+	OS.shell_open(OS.get_user_data_dir())
+